DEV Community

mamoor123
mamoor123

Posted on

I built a one-line observability decorator for Python AI agents

The problem

Your AI agents break and you find out when users complain. No logs, no metrics, no idea what went wrong.

The fix

A @observe decorator that tracks every call to local SQLite. No cloud, no API key, no signup.

How it works

from agentdna import observe

@observe
def transcribe(audio):
    return whisper.transcribe(audio)

@observe
def summarize(text):
    return llm.summarize(text)
markdown
markdown
## The problem

Your AI agents break and you find out when users complain. No logs, no metrics, no idea what went wrong.

## The fix

A `@observe` decorator that tracks every call to local SQLite. No cloud, no API key, no signup.

## How it works

Enter fullscreen mode Exit fullscreen mode


python
from agentdna import observe

@observe
def transcribe(audio):
return whisper.transcribe(audio)

@observe
def summarize(text):
return llm.summarize(text)
That's it. Every call is now logged with latency, success/failure, and error types.

View your stats
$ agentdna stats

📌 transcribe
✅ Healthy 42 calls ██████████ 97% avg 1250ms

📌 summarize
⚠️ Degraded 38 calls █████████░ 92% avg 3400ms
❌ 3 failures: Timeout(2), RateLimit(1)

Health thresholds:

✅ Healthy — 95%+ success rate
⚠️ Degraded — 80-95%
🔴 Unhealthy — below 80%

Features

Sync and async support
Latency percentiles (p50, p95, p99)
Error type breakdown
SQLite persistence — survives restarts
Zero dependencies beyond stdlib
Export to JSON or CSV

Install
pip install agentdna-sdk

Open source

Apache 2.0 —
GitHub

Built this because I was tired of debugging agents blind. Would love feedback!

Top comments (0)