Mohamed Ali Djemal · projects

AgentTracer

AgentTracer is a local-first visual debugger for AI agents — trace your LLM runs, inspect spans step-by-step, and understand agent behavior during development.

Why AgentTracer?

Existing observability tools (Langfuse, LangSmith) are built for production monitoring: dashboards, metrics, team collaboration. They’re heavy, require external services, and aren’t optimized for rapid local iteration.

AgentTracer is different:

  • Local-first — SQLite database, no external services, works entirely offline
  • Developer-focused — built for understanding agents during development, not monitoring in prod
  • Step-by-step — interactive tree view of every span, tool call, prompt, and response
  • Minimal setup — start backend, run traced agent, open UI
  • Python SDK — simple @trace_agent_run decorator or with Tracer() context manager

Architecture

┌─────────────────────────────────────────────┐
│ Your Agent Code │
│ (Python / LangChain / etc.) │
└─────────────────────┬───────────────────────┘
│ @trace_agent_run
┌─────────────────────────────────────────────┐
│ AgentTracer SDK │
│ @trace_agent_run │ Tracer │ HTTPExporter │
└─────────────────────┬───────────────────────┘
│ HTTP POST /api/v1/ingest/events
┌─────────────────────────────────────────────┐
│ AgentTracer Backend │
│ FastAPI + SQLite │
│ POST /ingest/events │ GET /runs │ GET /tree │
└─────────────────────┬───────────────────────┘
│ REST API
┌─────────────────────────────────────────────┐
│ AgentTracer Frontend │
│ React + TypeScript + Vite │
│ RunList │ TraceTree │ DetailsPanel │
└─────────────────────────────────────────────┘

Quick Start

Prerequisites

  • Python 3.12+ (backend) / 3.10+ (SDK)
  • Node.js 18+ (frontend)
  • uv (Python) — curl -LsSf https://astral.sh/uv/install.sh | sh

1. Start Backend

Terminal window
cd AgentTracer/backend
uv sync
uv run uvicorn agent_tracer.main:app --port 8000

API docs at http://localhost:8000/docs

2. Trace Your Agent (SDK)

Terminal window
cd AgentTracer/sdk
uv sync
from agent_trace_sdk import trace_agent_run
@trace_agent_run(name="my_agent")
def my_agent_function(user_input: str) -> str:
result = f"Processed: {user_input}"
return result
my_agent_function("What is the weather?")

Run: uv run python my_script.py

3. View Traces in UI

Terminal window
cd AgentTracer/frontend
npm install
npm run dev

Open http://localhost:3000 — see traced runs in sidebar, click to explore trace tree.

SDK Usage

Decorator (simplest)

from agent_trace_sdk import trace_agent_run
@trace_agent_run(name="research_agent")
def research(query: str) -> str:
return run_agent(query)
research("What is Python?")

Context Manager (more control)

from agent_trace_sdk import Tracer
with Tracer(name="my_agent") as span:
span.set_attribute("model", "gpt-4")
span.set_attribute("temperature", 0.7)
result = agent.run(user_input)
span.add_event("output", {"result": result})

What Gets Collected

  • Spans — each unit of work with start/end timestamps
  • Span typesagent_run, step, tool_call, llm_call
  • Attributes — key-value pairs on spans
  • Events — custom events like input, output, error
  • Parent-child relationships — nested spans form a tree

API Endpoints

MethodPathDescription
POST/api/v1/ingest/eventsAccept trace events from SDK
GET/api/v1/runsList runs (paginated)
GET/api/v1/runs/{id}Get run details
GET/api/v1/runs/{id}/treeGet trace tree
GET/api/v1/healthHealth check

Project Structure

AgentTracer/
├── backend/ # FastAPI + SQLite (Python)
│ ├── pyproject.toml
│ └── src/agent_tracer/
│ └── main.py # Single-file backend
├── sdk/ # Python tracing library
│ ├── pyproject.toml
│ └── src/agent_trace_sdk/
│ ├── tracer.py # Main tracer
│ ├── span.py # Span dataclass
│ ├── exporter.py # HTTP + Console exporters
│ ├── decorators.py # @trace_agent_run
│ └── domain/ # Data contracts
└── frontend/ # React + TypeScript UI
├── package.json
├── vite.config.ts
└── src/
├── App.tsx
└── components/ # RunList, TraceTree, DetailsPanel

Roadmap

  • Batch span processor with retry logic
  • @trace_span decorator for sub-steps
  • ContextVar-based automatic parent-child tracking
  • Framework integrations (LangChain, LlamaIndex, OpenAI SDK)
  • Enhanced visualization: timeline view, filtering, search
  • Run comparison (side-by-side diff)
  • Docker setup with docker-compose
  • PostgreSQL backend for larger deployments

Built for developers who want to understand their AI agents, step by step.