Skip to main content

Sentry for AI Agents โ€” one-line observability with local SQLite persistence

Project description

๐Ÿงฌ 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 included โ€” agentdna 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

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

agentdna_sdk-0.2.0.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

agentdna_sdk-0.2.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file agentdna_sdk-0.2.0.tar.gz.

File metadata

  • Download URL: agentdna_sdk-0.2.0.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agentdna_sdk-0.2.0.tar.gz
Algorithm Hash digest
SHA256 229dea6edd0963fdaf1bbf5e644c33151cd8619419209f484c0a561d7253d351
MD5 bf86909f1e84e717c1d2de5ca294597d
BLAKE2b-256 6e3b668b9e5977fe70df7acfc04ae0085c85207530a187af4976152c05ffa7fe

See more details on using hashes here.

File details

Details for the file agentdna_sdk-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: agentdna_sdk-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 34.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for agentdna_sdk-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8498b87f6c7607a9d9195483dc4bb0f37317c59d33466f6ef35dc7647d851212
MD5 e371fe8ee1ffe6719b88234297ba0250
BLAKE2b-256 ca01937f2ccff6792658677be6856bfacbe80078ea67d076f6152d61fc25ba3f

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