AgentLens Documentation

Observability and Explainability for AI Agents — see inside the black box.

version0.1.0 licenseMIT python3.9+ node18+

As AI agents become more autonomous — making decisions, calling tools, chaining actions — you need to see what they're doing and understand why. AgentLens is an open-source observability platform that gives you full visibility into agent behavior.

Why AgentLens?

📊

Session Tracing

Group agent actions into sessions. See the full execution trace with timing, tokens, and decision reasoning.

🛠️

Tool Call Capture

Record every tool invocation with inputs, outputs, and duration. Know exactly what your agent did and how long it took.

💰

Cost Tracking

Track token consumption and costs across models. Catch runaway spending before it becomes a problem.

🧠

Decision Traces

Capture the reasoning behind each agent decision. Understand the "why", not just the "what".

💡

Explainability

Generate human-readable summaries of agent behavior. Audit and debug without reading raw logs.

🎨

Zero-Config Decorators

Add @track_agent or @track_tool_call to your functions. Automatic instrumentation with no boilerplate.

How It Works

┌──────────────────┐ HTTP POST ┌──────────────────────┐ SQLite ┌──────────┐ │ Your Agent │ ───────────────────► │ AgentLens Backend │ ──────────────► │ DB │ │ + Python SDK │ /events │ (Express.js) │ └──────────┘ └──────────────────┘ └──────────┬───────────┘ │ │ serves / ▼ ┌──────────────────────┐ │ Dashboard │ │ (HTML / CSS / JS) │ └──────────────────────┘
  1. Instrument — Add the Python SDK to your agent. Use decorators or manual tracking.
  2. Collect — Events are batched and sent to the Express.js backend over HTTP.
  3. Store — Events and sessions are persisted in SQLite (zero external dependencies).
  4. Visualize — The built-in dashboard shows timelines, token charts, and explanations.

Quick Example

Pythonimport agentlens
from agentlens import track_agent, track_tool_call

# Initialize
agentlens.init(api_key="my-key", endpoint="http://localhost:3000")
session = agentlens.start_session(agent_name="my-agent")

# Decorate your functions — tracking is automatic
@track_tool_call(tool_name="web_search")
def search(query: str) -> list:
    return do_search(query)

@track_agent(model="gpt-4")
def my_agent(prompt: str) -> str:
    results = search(prompt)
    return synthesize(results)

# Run and explain
my_agent("What's the weather in Seattle?")
print(agentlens.explain())
agentlens.end_session()

Components

ComponentDirectoryTech StackPurpose
Python SDK sdk/ Python 3.9+, Pydantic, httpx Instrument agents with decorators or manual tracking
Backend API backend/ Node.js, Express, better-sqlite3 Ingest events, serve sessions, generate explanations
Dashboard dashboard/ Vanilla HTML/CSS/JS Visual timeline, token charts, session browser
💡 Ready to start?

Head to the Getting Started guide or try the 5-Minute Quickstart.