Skip to main content

Zero-config local-first visual debugging and auto-evaluation for LLM agents.

Project description

๐Ÿ” AgentTrace

Zero-config visual debugging and auto-evaluation for LLM agents.

License: MIT Python 3.9+ OpenTelemetry

One import. Zero config. Instant visual timeline of every LLM call, tool execution, and crash your agent makes.


The Problem

You build an AI agent. It calls an LLM, uses tools, chains prompts together. Then it hallucinates, loops infinitely, or silently drops context โ€” and you have no idea where it went wrong.

Every other observability tool requires accounts, API keys, cloud dashboards, and framework-specific setup. You just want to see what happened.

The Solution

import agenttrace.auto  # โ† That's it. One line.

# ... your existing agent code runs normally ...
# When it finishes, a local dashboard opens automatically at localhost:8000

AgentTrace intercepts every LLM call, tool execution, and unhandled crash โ€” then serves a beautiful local timeline you can replay step-by-step.


โœจ Features

๐Ÿช„ True Zero-Config

Add import agenttrace.auto to the top of your script. No API keys, no accounts, no cloud. Works with OpenAI, Groq, LangChain, and CrewAI out of the box.

๐Ÿง  Smart Auto-Judge

AgentTrace doesn't just show you what happened โ€” it tells you what went wrong:

Evaluation How It Works Cost
๐Ÿ” Loop Detection Flags 3+ identical consecutive tool calls Free (pure Python)
๐Ÿ’ฐ Cost Anomaly Flags steps using >2x average tokens Free (pure Python)
โฑ๏ธ Latency Regression Flags steps >3x slower than average Free (pure Python)
๐Ÿ”ง Tool Misuse Detects wrong arguments or failed tool calls LLM-powered (optional)
๐Ÿ“ Instruction Drift Detects when LLM ignores the system prompt LLM-powered (optional)

LLM-powered checks require a free Groq API key. Install with pip install "agenttrace-ai[judge]".

โ–ถ๏ธ Trace Replay

Press Play and watch your agent's execution animate step-by-step โ€” like a video recording of its thought process. Drag the scrubber to jump to any moment. Flagged steps pulse red.

๐Ÿ’ฅ Crash Detection

If your agent throws an unhandled exception, AgentTrace catches it and logs the full traceback as a trace step โ€” so you never lose debugging data.

๐Ÿ”Œ Framework Support

Framework Status Setup Required
OpenAI SDK โœ… Native pip install "agenttrace-ai[openai]"
Groq SDK โœ… Native pip install "agenttrace-ai[openai]"
LangChain โœ… Adapter None (auto-detected)
CrewAI โœ… Adapter None (auto-detected)

๐Ÿš€ Quickstart

Install

# Core (works with LangChain out of the box)
pip install agenttrace-ai

# With OpenAI/Groq support
pip install "agenttrace-ai[openai]"

# With everything (OpenAI + Auto-Judge + LangChain)
pip install "agenttrace-ai[all]"

Basic Usage (OpenAI / Groq)

import agenttrace.auto  # โ† Add this one line
import openai

client = openai.OpenAI()
response = client.chat.completions.create(
    model="gpt-4",
    messages=[{"role": "user", "content": "What is the capital of France?"}]
)
print(response.choices[0].message.content)
# Dashboard opens automatically at http://localhost:8000 when your script finishes

LangChain (Zero-Config)

import agenttrace.auto  # โ† Same one line
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate

llm = ChatOpenAI(model="gpt-4")
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a helpful assistant."),
    ("human", "{input}")
])

chain = prompt | llm
result = chain.invoke({"input": "Explain quantum computing"})
# All LLM calls automatically appear in the AgentTrace dashboard

Custom Tool Tracking

from agenttrace import track_tool, track_agent

@track_tool
def search_database(query: str) -> str:
    return db.search(query)

@track_agent
def my_agent(task: str) -> str:
    data = search_database(task)
    return llm.complete(f"Answer based on: {data}")

๐Ÿ—๏ธ Architecture

Your Agent Script
       โ”‚
       โ–ผ
  import agenttrace.auto
       โ”‚
       โ”œโ”€โ”€โ”€ OpenTelemetry TracerProvider
       โ”‚         โ”‚
       โ”‚         โ”œโ”€โ”€ OpenAI Instrumentor (optional)
       โ”‚         โ”œโ”€โ”€ LangChain Callback Adapter
       โ”‚         โ””โ”€โ”€ CrewAI Callback Adapter
       โ”‚         โ”‚
       โ”‚         โ–ผ
       โ”‚    AgentTraceExporter โ†’ SQLite (.agenttrace.db)
       โ”‚
       โ”œโ”€โ”€โ”€ sys.excepthook โ†’ Crash capture
       โ”‚
       โ””โ”€โ”€โ”€ atexit โ†’ FastAPI Server (localhost:8000)
                         โ”‚
                         โ”œโ”€โ”€ /api/traces
                         โ”œโ”€โ”€ /api/trace/{id}
                         โ””โ”€โ”€ React Dashboard (Vite + Tailwind)

Key Design Decisions

  • OpenTelemetry for instrumentation (industry standard, not fragile monkey-patching)
  • SQLite with WAL mode for zero-config persistence that survives crashes
  • contextvars for thread-safe multi-agent isolation
  • Pre-compiled React UI bundled inside the Python package

๐Ÿ“ Project Structure

agenttrace/
โ”œโ”€โ”€ auto.py              # Zero-config entry point (import this)
โ”œโ”€โ”€ exporter.py          # OTel SpanExporter โ†’ SQLite
โ”œโ”€โ”€ judge.py             # Smart Auto-Judge engine (5 eval types)
โ”œโ”€โ”€ models.py            # Pydantic data models
โ”œโ”€โ”€ storage.py           # SQLite with WAL mode
โ”œโ”€โ”€ server.py            # FastAPI dashboard server
โ”œโ”€โ”€ decorators.py        # @track_tool, @track_agent
โ”œโ”€โ”€ utils.py             # Payload truncation
โ”œโ”€โ”€ integrations/
โ”‚   โ”œโ”€โ”€ langchain.py     # LangChain callback adapter
โ”‚   โ””โ”€โ”€ crewai.py        # CrewAI callback adapter
โ””โ”€โ”€ static/              # Pre-compiled React dashboard

โš™๏ธ Configuration

Environment Variable Default Description
GROQ_API_KEY โ€” Required for LLM-powered judge evaluations
AGENTTRACE_DB_PATH .agenttrace.db Custom database file path
AGENTTRACE_FULL_PAYLOAD 0 Set to 1 to disable payload truncation
AGENTTRACE_MAX_CONTENT 500 Max characters before truncation

๐Ÿค Contributing

We welcome contributions! Here's how to set up the dev environment:

git clone https://github.com/CURSED-ME/AgentTrace.git
cd AgentTrace
pip install -e ".[all]"

# Frontend development
cd ui
npm install
npm run dev    # Dev server with hot reload
npm run build  # Compile to agenttrace/static/

See .env.example for required environment variables.


๐Ÿ“„ License

MIT License โ€” see LICENSE for details.


Built with โค๏ธ for the agent builder community.

If AgentTrace helped you debug an agent, give us a โญ on GitHub!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenttrace_ai-0.1.1.tar.gz (75.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenttrace_ai-0.1.1-py3-none-any.whl (75.7 kB view details)

Uploaded Python 3

File details

Details for the file agenttrace_ai-0.1.1.tar.gz.

File metadata

  • Download URL: agenttrace_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 75.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agenttrace_ai-0.1.1.tar.gz
Algorithm Hash digest
SHA256 251407a8fb50c87ad9a6cc506017737f7b09a6385e75c0a8737805a314ccd0d3
MD5 11db4b8c1abcbf137fbf9fda6def7cb0
BLAKE2b-256 fc2b523a863844694b40ef62d6cac2957f7a79d55f4ccde7944ddee4357ece3f

See more details on using hashes here.

File details

Details for the file agenttrace_ai-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: agenttrace_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 75.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agenttrace_ai-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d27627e5abf2aca96c5e6a8ff07856bb858c04845df7cfcb740e8a70c0be7d42
MD5 a4047b2e5eba7f54de5ae1441fe70c38
BLAKE2b-256 ec659dabb81a8dda4227256f9458ab3a4b3cad3381c4a759cd376a237ab5b7ea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page