Skip to main content

AgentTrace SDK

AI Agent Observability & Debugging - Record, replay, and debug your AI agents.

PyPI version Python 3.8+


🚀 Quick Start

pip install agenttrace-sdk
from agenttrace import AgentTrace

# Initialize with your API key
tracer = AgentTrace(api_key="at_your_api_key_here")

# Start a trace session
tracer.start("my_agent.py")

# Record agent activities
tracer.thought("Analyzing the user's request...")
tracer.tool_start("web_search", {"query": "latest AI news"})
tracer.tool_end("web_search", {"results": [...]})

# End the session
tracer.end()

📋 Features

  • 📍 Event Recording - Capture thoughts, tool calls, file writes, and exceptions
  • 🔄 Replay Execution - Re-run your agent with deterministic results
  • 🌿 Branch & Fork - Create alternate timelines from any point
  • 🔍 Compare Runs - Side-by-side diff of different executions
  • 🛠️ AutoFix Engine - AI-powered error detection and fixes

🔧 API Reference

Initialize Client

from agenttrace import AgentTrace

tracer = AgentTrace(
    api_key="at_xxx...",                    # Your API key (required)
    endpoint="https://app.agenttrace.io",   # API endpoint (optional)
    batch_size=10,                          # Events before auto-flush
    flush_interval=1.0                      # Seconds between flushes
)

Record Events

# Record a thought/reasoning step
tracer.thought("Planning the next action...")

# Record tool invocation
tracer.tool_start("calculator", {"expression": "2+2"})
tracer.tool_end("calculator", result=4)

# Record file operations
tracer.file_write("/path/to/file.txt", "content here")

# Record exceptions
tracer.exception("ValueError", "Invalid input", traceback_str)

Context Manager

with tracer.session("my_script.py") as trace_id:
    tracer.thought("Starting...")
    # Your agent code here
    # Automatically ends with status "completed" or "failed"

Decorator

from agenttrace import trace

@trace
def my_function(x, y):
    return x + y  # Automatically traced!

🔑 Get Your API Key

  1. Sign up at agenttrace.io
  2. Go to Settings → API Keys
  3. Create a new key
  4. Copy and use in your code
# Or set via environment variable
export AGENTTRACE_API_KEY="at_your_key_here"

# Then just:
tracer = AgentTrace()  # Auto-reads from env

📊 View Your Traces

After recording, view your traces at:

  • Dashboard: https://app.agenttrace.io/dashboard/traces
  • Individual Trace: https://app.agenttrace.io/trace/{trace_id}

🌐 Self-Hosted

For self-hosted deployments:

tracer = AgentTrace(
    api_key="at_xxx...",
    endpoint="https://your-domain.com"  # Your self-hosted instance
)

📄 License

MIT License - see LICENSE for details.

🔗 Links

Release files for agenttrace-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for agenttrace-sdk 1.0.0
File Size Uploaded
agenttrace_sdk-1.0.0.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agenttrace-sdk 1.0.0
File Interpreter ABI Platform
agenttrace_sdk-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.8 kB

Release files / agenttrace_sdk-1.0.0.tar.gz

Download URL agenttrace_sdk-1.0.0.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c6e7f1163d89e77a9850886b5dd8d69eaf115d214d082afb965f4b848bcbd5d9
BLAKE2b-256 checksum
How to use checksums
bef01ce7b47398dd11ee6068ed54d6d8e7a4cfb0ea72c3e8b32470c155f7f58b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release files / agenttrace_sdk-1.0.0-py3-none-any.whl

Download URL agenttrace_sdk-1.0.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0f9ec63bc00d29fbe6d0f88a279d80844ac139452d5f814b2b7216bf982e152
BLAKE2b-256 checksum
How to use checksums
7bfd57b0ee419947f186b18dc853dc138ad8dcf29be59f1f1b73c34948b57843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page