Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
Local-first AI agent debugger with fork & replay
Local-first AI agent debugger with fork & replay.
AgentLens captures execution traces from multi-step AI agent workflows, visualizes them in a local web UI, and lets you fork a trace at any step, edit its output, and re-execute downstream steps with real API calls to see what would have happened differently.
Think of it as Chrome DevTools for AI agents — the Network tab + time-travel debugging, but for LLM agent workflows.
Install:
pip install agentlens-xray— the import name isagentlens.
https://github.com/user-attachments/assets/416a853c-4915-4a30-8590-f50fd0a7dc47
AI agents are non-deterministic. When a multi-step agent fails at step 7 of 12, developers currently have no way to:
pip install agentlens-xray
python examples/basic_agent.py # creates a sample trace (no API keys needed)
agentlens serve # opens the UI at localhost:7600
For a real agent with OpenAI:
export OPENAI_API_KEY="sk-..."
python examples/trip_planner_agent.py
agentlens serve
Add decorators to your existing agent functions — zero logic changes:
import agentlens
@agentlens.trace(name="my_agent")
async def my_agent(query: str):
data = await fetch_data(query)
result = await analyze(data)
return result
@agentlens.wrap_tool(name="fetch_data")
async def fetch_data(query: str) -> dict:
return await api.search(query)
@agentlens.wrap_llm(name="analyze", model="gpt-4o-mini")
async def analyze(data: dict) -> str:
response = await openai.chat.completions.create(...)
return response.choices[0].message.content
There's also a context manager API:
async with agentlens.start_trace_async("my_agent") as t:
with t.span("fetch_data", kind="tool") as s:
data = await fetch(...)
s.record_output(data)
with t.span("analyze", kind="llm", model="gpt-4o") as s:
s.record_input({"messages": [...]})
result = await llm.complete(...)
s.record_output(result)
agentlens serve # Web UI at localhost:7600
agentlens serve --port 8080 # Custom port
agentlens traces # List recent traces in terminal
agentlens traces --last 5 # Show last 5
In the web UI:
| Mode | What happens | Cost | Use case |
|---|---|---|---|
| Deterministic | Only the edited span changes. Downstream spans are marked stale. | Free | Quick data annotation, bookmarking bugs |
| Live | All downstream spans re-execute with real API calls. | Token costs | "What would the LLM say if the tool returned different data?" |
| Hybrid | LLM spans re-execute live, tool spans return recorded data. | Lower token costs | Test LLM behavior with changed context, no tool side effects |
Example: Your weather tool returned "sunny" but the real weather is a blizzard. Fork the weather span, change it to blizzard, select Live mode. The LLM re-generates the itinerary accounting for severe weather — with real API calls, producing genuinely different output.
AgentLens works with popular frameworks out of the box — no decorators needed.
pip install agentlens-xray[openai] # or agentlens-xray[anthropic]
from openai import OpenAI
from agentlens import wrap_openai
client = wrap_openai(OpenAI())
# All chat.completions.create() calls are now traced automatically
response = client.chat.completions.create(model="gpt-4o", messages=[...])
pip install agentlens-xray[langchain]
from agentlens.integrations.langchain import AgentLensCallbackHandler
with AgentLensCallbackHandler(trace_name="my_agent") as handler:
chain.invoke(input, config={"callbacks": [handler]})
# Full trace with LLM, tool, retrieval, and chain spans
pip install agentlens-xray[openai-agents]
from agentlens.integrations.openai_agents import install_agentlens_tracing
install_agentlens_tracing() # One line — all agent runs traced automatically
result = await Runner.run(agent, input="Process this refund")
pip install agentlens-xray[crewai]
from agentlens.integrations.crewai import CrewAIHandler
handler = CrewAIHandler(trace_name="my_crew")
crew = Crew(agents=[...], tasks=[...], callbacks=[handler])
crew.kickoff() # Crew, agent, and task spans captured
pip install agentlens-xray and add decorators or use framework integrationse to editYour Agent Code
--> @trace, @wrap_tool, @wrap_llm decorators capture spans
--> Async queue --> SQLite (./.agentlens/traces.db)
--> FastAPI serves JSON API + bundled React frontend
--> localhost:7600
Fork & Replay (Live mode):
--> Load original trace, apply mutations
--> Re-import user's function, set ReplayContext
--> Decorators intercept each span:
Before mutation: execute normally
At mutation: return edited output
After mutation: execute live (real API calls)
--> Save new trace for side-by-side comparison
| Variable | Default | Description |
|---|---|---|
AGENTLENS_DB_PATH | ./.agentlens/traces.db | SQLite database path (project-local by default) |
AGENTLENS_PORT | 7600 | Default server port |
AGENTLENS_ENABLED | true | Set false to disable tracing (decorators become no-ops) |
# Install with dev dependencies
pip install -e ".[dev]"
# Frontend development (hot reload)
cd frontend && npm install && npm run dev
# Build frontend for production
cd frontend && npm run build
# Run tests
pytest
# Type checking
mypy src/agentlens
cd frontend && npx tsc --noEmit
src/agentlens/
sdk/ # Tracing SDK (decorators, context management, SQLite writer)
server/ # FastAPI API + static file serving
replay/
engine.py # Replay dispatcher (deterministic vs live)
live.py # Live replay engine (re-executes user functions)
context.py # ReplayContext (decorators check this at runtime)
cli.py # CLI entry point
frontend/ # React + TypeScript + Tailwind UI (Vite)
examples/ # Working examples (basic + OpenAI trip planner)
MIT
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.3.2 | 2 Apr 2026 | 17 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 22:34 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:d79a6d76806da90ffb32f88f31d95cecf424bd122f73cab0e71d4438723434cd