A lightweight, local-first agentic framework with tool calling, recursive sub-agents, and full execution tracing.
Project description
๐ค TrajectoryKit: An Agent Starter Pack
A lightweight, local-first agentic framework for HuggingFace models with built-in tool calling, recursive sub-agents, and full execution tracing.
๐๐จ Quickstart
from trajectorykit import dispatch
result = dispatch(
user_input="Compare the stats of Blue Eyes White Dragon vs Dark Magician",
turn_length=5,
verbose=True
)
print(result["final_response"])
The agent writes and executes code in a sandbox, returning results with inline images:
โจ Features
- ๐ 100% Local โ runs on your own GPU via vLLM, no API keys needed
- ๐ Agentic Loop โ iterative tool calling until the task is done
- ๐ค Recursive Sub-Agents โ spawn child agents to decompose complex tasks (up to 3 levels deep)
- ๐ป Sandboxed Code Execution โ run Python (and 40+ languages) in an Apptainer sandbox with file I/O
- ๐ Web Search โ built-in Google search via SerpAPI
- ๐ Full Execution Tracing โ every turn, tool call, token count, and sub-agent is recorded
- ๐ HTML Trace Viewer โ self-contained dark-themed trace pages with collapsible reasoning, inline images, and token stats
๐ฆ Package Structure
src/trajectorykit/
โโโ __init__.py # Public API: dispatch, EpisodeTrace, render_trace_html, render_trace_file
โโโ config.py # Model, API URL, traces directory, system prompt
โโโ agent.py # Core agentic loop with tool dispatch and trace building
โโโ tool_store.py # Tool definitions + wrapper functions
โโโ tracing.py # Dataclasses, pretty-print, JSON/HTML serialization
โโโ examples.py # Ready-to-run examples
โโโ serve_vllm.sh # Script to launch vLLM server
traces/ # Auto-created directory for saved traces (JSON + HTML)
๐ Built-in Tools
| Tool | Description |
|---|---|
execute_code |
Run code in a sandboxed Apptainer container. Supports file upload (files) and retrieval (fetch_files) as base64. |
search_web |
Google search via SerpAPI. Returns titles, snippets, and links. |
get_current_time |
Returns the current date and time. |
add_numbers |
Adds two numbers (demo tool). |
spawn_agent |
Spawns a recursive sub-agent with its own tool access and trace. |
๐ Recursive Sub-Agents
Dispatch can spawn child agents to handle subtasks independently. Each sub-agent runs its own agentic loop with full tool access and produces its own trace, nested inside the parent's trace tree.
from trajectorykit import dispatch
result = dispatch(
user_input=(
"How has the market price of the card 'Blue-Eyes White Dragon' moved over the last years?"
),
turn_length=5,
max_tokens=4096
)
result["trace"].pretty_print()
Max recursion depth is controlled by MAX_RECURSION_DEPTH in config.py (default: 3).
๐ Tracing
Every dispatch() call returns a full execution trace in result["trace"].
Pretty-print to terminal
result["trace"].pretty_print()
๐ Agent [root] trace_id=154b9f2e
Input: What is the current time? What is 123 + 456?
Duration: 8.42s | Turns: 2 | Tool calls: 2
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโ Turn 1 (4.00s)
โ ๐ง get_current_time({}) [0.01s]
โ โ 2026-02-19 21:04:29
โ ๐ง add_numbers({"a": 123, "b": 456}) [0.00s]
โ โ 579
โโ
...
๐ Episode Summary:
Prompt tokens: 3,621
Completion tokens: 686
Total tokens: 4,307
Save to disk
path = result["trace"].save()
# Writes traces/trace_20260219_210429_154b9f2e.json
# Also writes traces/trace_20260219_210429_154b9f2e.html
Traces are saved to the traces/ directory automatically.
HTML trace viewer
The HTML file is a self-contained dark-themed page with:
- Prompt at the top (always visible)
- Stats bar โ duration, turns, tool calls, sub-agents, total tokens (prompt + completion)
- Collapsible trace detail โ starts collapsed, expand to drill into turns
- Reasoning dropdowns โ model chain-of-thought shown per turn
- Inline images โ plots and generated images rendered directly
- Final response at the bottom (always visible)
You can also render any trace JSON to HTML:
from trajectorykit import render_trace_file
render_trace_file("traces/trace_20260219_210429_154b9f2e.json")
โ๏ธ Configuration
All settings live in config.py:
| Setting | Default | Description |
|---|---|---|
MODEL_NAME |
Qwen/Qwen3-8B |
HuggingFace model served by vLLM |
VLLM_API_URL |
http://localhost:3030/v1 |
vLLM OpenAI-compatible endpoint |
MAX_RECURSION_DEPTH |
3 |
Max sub-agent nesting depth |
TRACES_DIR |
<repo_root>/traces/ |
Where .json and .html traces are saved |
๐ Running
1. Install conda env
conda env create -f environment. yml.
2. Start the Apptainer sandbox (code execution)
bash src/trajectorykit/apptainer.sh
This pulls and runs the SandboxFusion container, exposing a code execution API on http://localhost:8080.
3. Start vLLM
bash src/trajectorykit/serve_vllm.sh
4. Run an example
cd src && python -m trajectorykit.examples
API
result = dispatch(
user_input="Your task here",
turn_length=5, # Max turns (None = unlimited)
verbose=True, # Print turn-by-turn output
max_tokens=2000, # Max tokens per generation
temperature=0.7, # Sampling temperature
)
# result keys:
result["final_response"] # str โ the model's final answer
result["turns"] # int โ number of turns taken
result["tool_calls"] # int โ total tool calls made
result["messages"] # list โ full conversation history
result["trace"] # EpisodeTrace โ full execution tree
๐ Citation
If you use TrajectoryKit in your research or project, please cite it:
@software{trajectorykit2026,
title={TrajectoryKit: An Agent Starter Pack},
author={Lugoloobi, William},
year={2026},
url={https://github.com/KabakaWilliam/TrajectoryKit}
}
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trajectorykit-0.1.0.tar.gz.
File metadata
- Download URL: trajectorykit-0.1.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0265cdf53438859e69f49480c574f0bd2f7136dab909590cf94638c8eb93484f
|
|
| MD5 |
2f7548f9a4cc62e35253a7ef150aadfb
|
|
| BLAKE2b-256 |
c0372f394f8f6424f52b158f5eec454608aba98d7e877e7816cb44e1350db34f
|
File details
Details for the file trajectorykit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: trajectorykit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 29.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25741d74ec7dc178363ab55071e2a225f8276401a996bad28e7197bba9939e3d
|
|
| MD5 |
5f1696963f8daa18c3a238797a14fc14
|
|
| BLAKE2b-256 |
73af2991fb8294ca84206b5d97724d4b97304957eb8c94c17b96d232c12a46bb
|