agtrace-sdk
The Observability Platform for AI Agents (Public SDK)
agtrace-sdk provides a high-level, stable API for building observability tools on top of agtrace. It abstracts away the internal complexity of providers, indexing, and runtime orchestration, exposing only the essential primitives for monitoring and analyzing AI agent behavior.
Features
- Universal Normalization: Works with multiple AI agent providers (Claude, Codex, Gemini)
- Real-time Monitoring: Watch for live events as agents interact
- Session Analysis: Analyze agent sessions with built-in diagnostic lenses
- Clean API: Simple, type-safe interface for common observability tasks
Architecture
This SDK acts as a facade over:
agtrace-types: Core domain models (AgentEvent, etc.)agtrace-providers: Multi-provider log normalizationagtrace-engine: Session analysis and diagnosticsagtrace-index: Metadata storage and queryingagtrace-runtime: Internal orchestration layer
Stability Guarantee
- agtrace-sdk: Semantic Versioning (SemVer) strictly followed. Public API is stable.
- Internal crates (
agtrace-runtime,agtrace-engine, etc.): Internal APIs, subject to breaking changes without notice.
If you're building tools on top of agtrace, use only the agtrace-sdk crate to ensure stability across updates.
Installation
Add this to your Cargo.toml:
[]
= "0.1.13"
Usage
Basic Example
use ;
Real-time Monitoring
use Client;
Provider-specific Monitoring
use Client;
Diagnostic Lenses
The SDK provides several built-in lenses for analyzing agent behavior:
- Failures: Detects tool execution failures
- Loops: Detects repetitive patterns that might indicate infinite loops
- Bottlenecks: Identifies slow tool executions (>10 seconds)
Use Cases
Building a Monitoring Dashboard
use ;
Dead Man's Switch (vital-checker)
use Client;
use ;
API Reference
Client
Client::connect(path): Connect to an agtrace workspace.watch(): Create a watch builder for real-time monitoring.session(id): Get a handle to a specific session
SessionHandle
.events(): Get all normalized events for the session.summary(): Get a summary of the session
WatchBuilder
.provider(name): Filter events by provider.all_providers(): Watch all configured providers.start(): Start monitoring and return a live stream
LiveStream
Implements the Iterator trait for ergonomic event processing.
.next_blocking(): Block until next event arrives.try_next(): Try to get next event without blocking
Analysis
analyze_session(session): Create an analyzer for a session.through(lens): Apply a diagnostic lens.report(): Generate analysis report
Contributing
Contributions are welcome! Please see the main agtrace repository for contribution guidelines.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.