agtrace-sdk
Installation
Add this to your Cargo.toml:
[]
= "0.5"
agtrace-sdk: SDK for AI agent observability.
Note: README.md is auto-generated from this rustdoc using cargo-rdme.
To update: cargo rdme --workspace-project agtrace-sdk
Overview
agtrace-sdk provides a high-level, stable API for building tools on top of agtrace.
It powers agtrace's MCP server (letting agents query their execution history) and CLI tools,
and can be embedded in your own applications. The SDK normalizes logs from multiple providers
(Claude Code, Codex, Gemini) into a unified data model, enabling cross-provider analysis.
Quickstart
use ;
// Connect to the local workspace
let client = connect_default.await?;
// List sessions and browse the most recent one
let sessions = client.sessions.list?;
if let Some = sessions.first
For complete examples, see the examples/ directory.
Architecture
This SDK acts as a facade over:
agtrace-types: Core domain models (AgentEvent, etc.)agtrace-providers: Multi-provider log normalizationagtrace-engine: Session assembly and analysisagtrace-index: Metadata storage and queryingagtrace-runtime: Internal orchestration layer
Usage Patterns
Session Browsing
Access structured session data (Turn → Step → Tool hierarchy):
use ;
let client = connect_default.await?;
let sessions = client.sessions.list?;
for summary in sessions.iter.take
Real-time Monitoring
Watch for events as they happen:
use Client;
use StreamExt;
let client = connect_default.await?;
let mut stream = client.watch.all_providers.start?;
while let Some = stream.next.await
Diagnostics
Run diagnostic checks on sessions:
use ;
let client = connect_default.await?;
let sessions = client.sessions.list?;
if let Some = sessions.first
Standalone API (for testing/simulations)
use ;
// When you have raw events without Client (e.g., testing, simulations)
let events: = vec!;
let handle = from_events;
let session = handle.assemble?;
println!;
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.