pub struct UsageReporter { /* private fields */ }Expand description
Reporter that aggregates token usage and cost across the entire run.
UsageReporter listens for AgentEvent::UsageUpdated and
AgentEvent::TurnFinished events and maintains a running
UsageSummary. After the loop completes, call summary
to read the totals.
§Example
use agentkit_reporting::UsageReporter;
use agentkit_loop::LoopObserver;
let mut reporter = UsageReporter::new();
// ...pass `reporter` to the agent loop, then afterwards:
let summary = reporter.summary();
println!(
"tokens: {} in / {} out",
summary.totals.input_tokens,
summary.totals.output_tokens,
);Implementations§
Source§impl UsageReporter
impl UsageReporter
Sourcepub fn summary(&self) -> &UsageSummary
pub fn summary(&self) -> &UsageSummary
Returns a reference to the current UsageSummary.
Trait Implementations§
Source§impl Default for UsageReporter
impl Default for UsageReporter
Source§fn default() -> UsageReporter
fn default() -> UsageReporter
Returns the “default value” for a type. Read more
Source§impl LoopObserver for UsageReporter
impl LoopObserver for UsageReporter
Source§fn handle_event(&mut self, event: AgentEvent)
fn handle_event(&mut self, event: AgentEvent)
Called synchronously for every
AgentEvent emitted by the loop driver.Auto Trait Implementations§
impl Freeze for UsageReporter
impl RefUnwindSafe for UsageReporter
impl Send for UsageReporter
impl Sync for UsageReporter
impl Unpin for UsageReporter
impl UnsafeUnpin for UsageReporter
impl UnwindSafe for UsageReporter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more