Chrome DevTools for AI Agents. Capture, replay, and inspect every LLM call, tool invocation, and decision in your multi-agent workflows.
π― The Problem: Multi-agent AI systems are a black box. When an agent fails, burns money in a loop, or makes a bad decision β you have no way to see why.
π‘ The Solution: AgentLens captures every step and lets you replay, inspect, and debug the entire execution like a video player with a timeline scrubber.
Scrub through your agent's entire execution timeline. Click any step to see exactly what happened β the full prompt, response, tokens, cost, and decision rationale.
Real-time token & cost tracking per agent, per step, per model. Know exactly where your money is going.
Automatic detection of:
- Infinite loops β Agent stuck in fixβtestβfail cycles
- Token escalation β Context window growing out of control
- Repeated prompts β 85%+ similarity with previous prompts
- Empty responses β Model returned nothing useful
Dedicated panel for Model Context Protocol tool invocations. See which MCP servers were called, with what params, and what they returned.
Color-coded agent badges, agent flow trees, and per-agent cost breakdowns. See your entire orchestration at a glance.
Play, pause, step forward, reset. Scrub through the timeline like a video player.
git clone https://github.com/ModernOps888/agentlens.git
cd agentlens
npm install
npm run devOpen http://localhost:3000 β the app ships with built-in demo data showing:
- Successful workflow: A 5-agent LinkedIn blog post pipeline (Orchestrator β Researcher β Writer β Editor β Publisher)
- Failed workflow: A coding agent caught in an infinite fix-test loop with automatic halt
pip install requestsfrom agentlens import AgentLens
# Start a trace session
lens = AgentLens(session_name="My Agent Pipeline")
# Option A: Wrap OpenAI (automatic tracing β zero code changes)
from openai import OpenAI
client = lens.wrap_openai(OpenAI(), agent_name="MyAgent")
response = client.chat.completions.create(model="gpt-4o", messages=[...])
# ^ Every call is now traced in AgentLens!
# Option B: Wrap Anthropic (Claude)
from anthropic import Anthropic
client = lens.wrap_anthropic(Anthropic(), agent_name="ClaudeAgent")
response = client.messages.create(model="claude-4-sonnet", max_tokens=1024, messages=[...])
# Option C: Wrap Google Gemini
import google.generativeai as genai
model = lens.wrap_google(genai.GenerativeModel("gemini-2.5-flash"), agent_name="GeminiAgent")
response = model.generate_content("Explain quantum computing")
# Option D: Wrap Ollama (local LLMs β no package needed)
ollama = lens.wrap_ollama(agent_name="LocalLLM")
response = ollama.chat(model="llama3", messages=[{"role": "user", "content": "Hello!"}])
# Option E: Wrap LiteLLM (any provider via proxy)
import litellm
litellm.callbacks = [lens.wrap_litellm(agent_name="MultiModel")]
# Option F: Manual tracing
lens.trace_llm_call(
agent_name="Researcher",
model="gpt-4o",
prompt="Research this topic...",
response="Here are the findings...",
tokens={"prompt_tokens": 150, "completion_tokens": 200, "total_tokens": 350},
)
# Trace tool calls, MCP invocations, agent spawns, decisions, errors
lens.trace_tool_call(agent_name="Coder", tool_name="file_read", tool_input={"path": "main.py"})
lens.trace_mcp_call(agent_name="Agent", server_name="web-search", tool_name="search", params={"q": "..."})
lens.trace_agent_spawn(parent_agent="Orchestrator", spawned_agent="Writer")
lens.trace_decision(agent_name="Orchestrator", reason="Quality score 9/10, proceeding")
lens.trace_error(agent_name="Coder", error_message="Test failed: assertion error")
lens.end() # Mark session completeNote: Copy
sdk/python/agentlens.pyinto your project, or add it to your Python path. The SDK sends traces tohttp://localhost:3000/api/ingestby default.
# Send a trace step
curl -X POST http://localhost:3000/api/ingest \
-H "Content-Type: application/json" \
-d '{"session_id":"my-session","session_name":"Test","agent_name":"Agent1","step_type":"llm_call","model":"gpt-4o","prompt":"Hello","response":"Hi there"}'
# End a session
curl -X POST "http://localhost:3000/api/ingest?action=end" \
-H "Content-Type: application/json" \
-d '{"session_id":"my-session","status":"completed"}'
# Get all live sessions
curl http://localhost:3000/api/ingestβββββββββββββββββββββββββββββββββββββββββββββββ
β AgentLens β
β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
β β Proxy β β Recorder β β Storage β β
β β (capturesββ β (structs ββ β (SQLite / β β
β β calls) β β traces) β β JSON) β β
β ββββββββββββ ββββββββββββ βββββββββββββ β
β β β β
β ββββββββββββ βββββββββββββ β
β β Your AI β β Web UI β β
β β Agent β β (Timeline β β
β β Code β β Replay β β
β ββββββββββββ β Inspector)β β
β βββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββ
| Component | Technology |
|---|---|
| Frontend | Next.js 16 + React + TypeScript |
| Styling | Vanilla CSS (dark mode, glassmorphism) |
| Storage | SQLite + JSON |
| Fonts | Inter + JetBrains Mono |
| Provider | Models | Auto-Wrap | Cost Tracking |
|---|---|---|---|
| OpenAI | GPT-4o, GPT-4o-mini, o1, o3 | wrap_openai() |
β |
| Anthropic | Claude 4 Opus/Sonnet, Claude 3.5 | wrap_anthropic() |
β |
| Gemini 2.0/2.5 Flash/Pro | wrap_google() |
β | |
| Ollama | Llama 3, DeepSeek, Mistral, CodeLlama | wrap_ollama() |
β (free) |
| LiteLLM | Any provider via LiteLLM proxy | wrap_litellm() |
β |
| Custom | Any OpenAI-compatible API | Manual | β (configurable) |
AgentLens pairs with MCPlex to create a complete agent toolkit:
- MCPlex = execution layer (routes, secures, caches MCP tools)
- AgentLens = observability layer (traces, debugs, replays, alerts)
Enable the bridge in MCPlex's mcplex.toml:
[agentlens]
enabled = true
url = "http://127.0.0.1:3000/api/ingest"
session_name = "MCPlex Gateway"Every tool call through MCPlex now appears as a traced step in AgentLens's timeline. Both tools work 100% independently β the bridge is opt-in.
AgentLens exposes an MCP server so IDE agents (Antigravity, Claude Code, Cursor, Windsurf) can query traces:
{
"mcpServers": {
"agentlens": {
"command": "node",
"args": ["path/to/agentlens/src/mcp-server-entry.mts"],
"env": { "AGENTLENS_URL": "http://127.0.0.1:3000" }
}
}
}Available tools:
| Tool | Description |
|---|---|
agentlens_list_sessions |
List recent sessions with cost/anomaly summary |
agentlens_get_session |
Full session with all steps |
agentlens_search_traces |
Cross-session search by text, agent, type |
agentlens_get_anomalies |
All detected anomalies |
agentlens_get_cost_summary |
Cost breakdown by agent/model/provider |
# Run AgentLens standalone
docker build -t agentlens .
docker run -p 3000:3000 agentlens
# Run AgentLens + MCPlex together
docker-compose up- Debug failing agents β See exactly where and why an agent went wrong
- Optimize costs β Find expensive agents and reduce token usage
- Detect loops β Catch infinite fixβtestβfail cycles before they burn your budget
- Compare runs β Diff successful vs failed executions side-by-side
- Audit workflows β Full trace of every decision for compliance and review
- Demo & showcase β Beautiful UI for showing off your agent architecture
- Run comparison (diff view) β
- Export traces to JSON β
- Search & filter timeline β
- Keyboard shortcuts β
- OpenTelemetry export format β
- Budget alerts & cost projections β
- Live streaming simulation β
- Python SDK & REST API β
- Real-time trace streaming (SSE) β
- LangGraph / CrewAI / AutoGen framework adapters β
- Team collaboration (shared traces) β
- VS Code extension β
- npm package (
agentlens-sdk) β - Anthropic (Claude) auto-tracing β
- Google (Gemini) auto-tracing β
- Ollama local LLM tracing β
- LiteLLM universal proxy tracing β
- Google ADK adapter β
- MCPlex integration bridge β
- MCP server for IDE agents β
- Cross-session search API β
- Docker & docker-compose β
- Async Python SDK (aiohttp) β
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
MIT License. See LICENSE for details.
Built with β€οΈ for the AI agent community
If this tool saved you from a $47 infinite loop, consider giving it a β




