Skip to main content

🧬 AgentDNA — Sentry for AI Agents

One-line observability for any Python agent. No framework required. No API key. No network calls.

pip install agentdna

Quick Start

from agentdna import observe, get_stats

@observe
def my_agent(prompt):
    # your existing agent code
    return llm.call(prompt)

my_agent("hello world")

# View stats (persists across restarts)
print(get_stats())

That's it. One decorator. Full observability.

What You Get

📊 Stats: my_agent
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Health:           ✅ Healthy
  Total calls:      42
  Success rate:     97.6%
  Failed calls:     1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Avg latency:      1250.5 ms
  P50 latency:      980.0 ms
  P95 latency:      2100.0 ms
  P99 latency:      3500.0 ms
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  Errors:
    Timeout: 1
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Features

  • 📊 Call tracking — total calls, success/failure rates
  • ⏱️ Latency — avg, p50, p95, p99 percentiles
  • ❌ Error tracking — error types and frequency
  • 💾 SQLite persistence — data survives restarts
  • 🔒 100% local — no network calls, no API key
  • 🐍 Sync & async — works with both
  • 🖥️ CLI includedagentdna stats

CLI

agentdna stats                    # overview of all observed functions
agentdna stats my_agent           # detailed view
agentdna stats --export json      # export as JSON
agentdna stats --export csv       # export as CSV
agentdna stats --reset            # clear all data

Usage

Basic

from agentdna import observe

@observe
def my_agent(prompt):
    return llm.call(prompt)

With Options

@observe(name="transcriber", tags={"version": "2.0", "model": "whisper"})
def transcribe(audio_path):
    return whisper.transcribe(audio_path)

Async Support

@observe
async def my_async_agent(prompt):
    result = await llm.acall(prompt)
    return result

Get Stats Programmatically

from agentdna import get_stats

stats = get_stats("my_agent")
print(f"Success rate: {stats['success_rate']:.1%}")
print(f"P95 latency: {stats['p95_latency_ms']:.0f}ms")

# All functions
all_stats = get_stats()
for name, s in all_stats.items():
    print(f"{name}: {s['total_calls']} calls")

Export Stats

from agentdna import export_stats

json_str = export_stats(format="json")
csv_str = export_stats(format="csv")

How It Works

  1. Decorator wraps your function
  2. Each call logs: timestamp, success/failure, latency, input/output sizes, errors
  3. Data batches to ~/.agentdna/observe.db (SQLite, WAL mode)
  4. Read stats anytime via get_stats() or agentdna stats

No dependencies beyond Python stdlib. click is only needed for the CLI.

Data Location

Default: ~/.agentdna/observe.db

Custom path:

import os
os.environ["AGENTDNA_DB_PATH"] = "/path/to/my/observe.db"

Why AgentDNA?

Without AgentDNA With AgentDNA
print("done!") Track every call with latency + errors
Hope nothing breaks Know exactly when and what breaks
Debug blind P95 latency, error breakdown, trends
Lose data on restart SQLite persistence

Installation

pip install agentdna

Optional features:

pip install agentdna[discovery]   # agent discovery (httpx, PyYAML)
pip install agentdna[server]      # run registry server (FastAPI)

License

Apache 2.0

Release files for agentdna-sdk 0.2.1

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

Source distribution (sdist)

Source distribution for agentdna-sdk 0.2.1
File Size Uploaded
agentdna_sdk-0.2.1.tar.gz 26.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for agentdna-sdk 0.2.1
File Interpreter ABI Platform
agentdna_sdk-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 61.4 kB

Release files / agentdna_sdk-0.2.1.tar.gz

Download URL agentdna_sdk-0.2.1.tar.gz
Size 26.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2b7489fccd45b352f038fe3a5896998ba4e16cba09dd118ff9aa510b07a5eb2e
BLAKE2b-256 checksum
How to use checksums
2d5b1b952eebadf79a30322352308763f13dbef2434f51ea0a4b78da789fe16d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / agentdna_sdk-0.2.1-py3-none-any.whl

Download URL agentdna_sdk-0.2.1-py3-none-any.whl
Size 34.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9208ca111cf5c6baf93fbafdeb0687774b4a032acf668d7ab8793d202c16fcf
BLAKE2b-256 checksum
How to use checksums
a59c5d53a0277d47a6926ee4c5071924b2843a1bcce8c71535991805fcdb73bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.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