agentkit-reporting
Observers for turning loop events into logs, summaries, and transcript views.
This crate provides [LoopObserver] implementations for [agentkit-loop].
Instead of baking reporting into the driver, you attach one or more reporters
to the loop and they react to every AgentEvent that flows through it.
Included reporters
| Reporter | Purpose |
|---|---|
StdoutReporter |
Human-readable bracketed log lines ([turn] started ...) |
JsonlReporter |
Machine-readable newline-delimited JSON envelopes |
UsageReporter |
Aggregated token counts and cost totals |
TranscriptReporter |
Growing snapshot of conversation items |
CompositeReporter |
Fan-out wrapper that forwards events to multiple reporters |
Quick start
Compose several reporters with CompositeReporter and hand it to the loop:
use ;
// Build a composite reporter that fans out to all four reporters.
let reporter = new
.with_observer
.with_observer
.with_observer
.with_observer;
// Pass `reporter` as the observer when constructing the agent loop.
Accessing outputs after the loop
Reporters that accumulate state (UsageReporter, TranscriptReporter,
JsonlReporter) expose accessors for reading back data once the loop
finishes:
use ;
// Usage totals
let reporter = new;
// ...run the loop...
let summary = reporter.summary;
println!;
// Transcript items
let reporter = new;
// ...run the loop...
for item in &reporter.transcript.items
// JSONL buffer
let mut reporter = new;
// ...run the loop...
let jsonl = Stringfrom_utf8.unwrap;
let errors = reporter.take_errors;
assert!;
Writing to a file
JsonlReporter and StdoutReporter accept any std::io::Write
implementation, so you can point them at files, network sockets, or
in-memory buffers:
use JsonlReporter;
use BufWriter;
use File;
let file = create.expect;
let reporter = new;
Error handling
JsonlReporter and StdoutReporter never panic on write failures.
Errors are collected internally and can be drained after the loop with
take_errors(). This keeps the LoopObserver::handle_event signature
infallible while still giving you full visibility into any I/O issues.