AgentD
Observability for AI Agents. Open spec. Self-host or use our platform.
Drop-in replacement for claude_agent_sdk.query() that adds metrics, tracing, and cost tracking.
# Before
from claude_agent_sdk import query
# After (that's it)
from agentd import query
Why?
You built an agent. It works locally. Now what?
- Where do I see what it did? → AgentD logs every tool call, duration, and token usage
- How much is this costing me? → Automatic cost tracking per run
- Why did it fail? → Full traces with inputs and outputs
Quick Start
Install
pip install agentd-sdk
Requires Claude Agent SDK
Use
import asyncio
from agentd import query
from claude_agent_sdk import ClaudeAgentOptions
async def main():
options = ClaudeAgentOptions(
allowed_tools=["WebSearch", "Read", "Write"],
permission_mode="acceptEdits",
)
async for message in query(
prompt="Research the latest AI agent frameworks",
options=options,
agent_id="my-research-agent", # Optional: group runs
):
print(message)
asyncio.run(main())
That's it. You'll see a summary printed after each run:
============================================================
📊 AGENT RUN SUMMARY
============================================================
Run ID: 550e8400-e29b-41d4-a716-446655440000
Agent: my-research-agent
Status: completed
Duration: 12,340ms, API: 11,200ms, Overhead: 1,140ms
TTFT: 890ms
Turns: 5
Model: claude-sonnet-4-5-20250929
Tokens: 15,230 in / 3,200 out (cache: 2,100 read)
Cost: $0.0936 (SDK)
Trace: a1b2c3d4e5f6a7b8...
📦 Tool Usage:
• WebSearch: 3x (1200ms) [✓]
• Read: 2x (50ms) [✓]
• Write: 1x (30ms) [✓]
============================================================
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
AGENTD_URL |
HTTP endpoint to send metrics | None (console mode) |
AGENTD_API_KEY |
API key for authentication | None |
AGENTD_AGENT_ID |
Default agent ID | None |
AGENTD_DISABLED |
Set to "true" to disable | false |
AGENTD_QUIET |
Set to "true" to suppress console output | false |
AGENTD_STREAMING |
Real-time event streaming | false |
Programmatic Configuration
from agentd import configure
configure(
endpoint_url="https://your-receiver.com",
api_key="your-api-key",
agent_id="default-agent-id",
include_trace=True,
include_prompt=False,
)
Output Modes
Console (Default)
No config needed. Prints summary to stdout. Great for local development.
# Suppress console output
export AGENTD_QUIET=true
HTTP
Set AGENTD_URL to send data to a receiver:
export AGENTD_URL=https://your-receiver.com/v1/runs
export AGENTD_API_KEY=your-key
Disabled
export AGENTD_DISABLED=true
Alternative Usage Patterns
Wrapper Function
Keep using claude_agent_sdk.query() directly:
from claude_agent_sdk import query
from agentd import tracked_query
async for message in tracked_query(
query(prompt="...", options=options),
agent_id="my-agent"
):
print(message)
Context Manager
For fine-grained control:
from claude_agent_sdk import query
from agentd import track_run
async with track_run(agent_id="my-agent") as tracker:
async for message in query(prompt="...", options=options):
tracker.process_message(message)
# Custom processing here
Self-Hosting
We provide a reference receiver implementation. Run it, modify it, or use it to learn the spec.
Quick Start
cd receiver
pip install -r requirements.txt
python receiver.py
The receiver runs at http://localhost:8080. Point your SDK at it:
export AGENTD_URL=http://localhost:8080
What You Get
- SQLite storage (swap for Postgres, ClickHouse, etc.)
- REST API for querying data
- Ready for Grafana dashboards
API Spec
See spec/API.md for the full API contract. Build your own receiver if you want.
Data Model
AgentRun
{
"run_id": "uuid",
"agent_id": "my-agent",
"status": "completed",
"duration_ms": 12340,
"api_duration_ms": 11200,
"first_token_ms": 890,
"num_turns": 5,
"tokens": {"input": 15230, "output": 3200, "cache_read": 2100, "cache_write": 0},
"cost_usd": 0.0936,
"trace_id": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6",
"span_id": "a1b2c3d4e5f6a7b8",
"tool_calls": [
{"tool": "WebSearch", "count": 3, "total_duration_ms": 1200}
],
"events": [/* full trace */]
}
RunEvent
{
"event_id": "uuid",
"type": "tool_call",
"timestamp": "2025-01-15T10:30:00Z",
"sequence_number": 5,
"tool_name": "WebSearch",
"tool_id": "toolu_123",
"tool_input": {"query": "AI agents"},
"tool_duration_ms": 400,
"tool_success": true
}
Philosophy
- Open spec — The API contract is public. Build your own receiver, use ours, or switch later.
- No lock-in — Remove AgentD and your agent still works. It's just a wrapper.
- Start simple — Console output by default. Add infrastructure as you need it.
License
MIT
Contributing
Issues and PRs welcome. See CONTRIBUTING.md.
Metadata
Release files for agentd-sdk 0.6.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| agentd_sdk-0.6.0.tar.gz | 58.5 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| agentd_sdk-0.6.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 76.7 kB
Release files / agentd_sdk-0.6.0.tar.gz
| Download URL | agentd_sdk-0.6.0.tar.gz |
|---|---|
| Size | 58.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74c5a4978f3d9c508bfe26acb265be1d848679e5807db0e84934c784d186f712
|
|
BLAKE2b-256 checksum How to use checksums |
14b2b06b172b832e8323ec37971cba49c0cd73cfde26041cdd42734d6c2ef4c4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logRelease files / agentd_sdk-0.6.0-py3-none-any.whl
| Download URL | agentd_sdk-0.6.0-py3-none-any.whl |
|---|---|
| Size | 18.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bca12bd38f4128893118b73f00a609b9e7b1628b8696315a3f0c574ea11dd792
|
|
BLAKE2b-256 checksum How to use checksums |
a93ce65bc0afd5968f7a23dba2c7a6aeab373922d79c9f10eca80309c82de513
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logSecurity for agentd-sdk 0.6.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for agentd_sdk-0.6.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jan 19, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.