pub struct SessionUsageTracker { /* private fields */ }Expand description
Billable usage for one agent session. The root agent’s session tracker captures totals for all agents (e.g. sub-agents).
Implementations§
Source§impl SessionUsageTracker
impl SessionUsageTracker
pub fn new(agent_name: impl Into<String>) -> Self
Sourcepub fn resume_from(&mut self, last: &SessionUsageEvent)
pub fn resume_from(&mut self, last: &SessionUsageEvent)
Continue from the last persisted event so a resumed session keeps its totals.
pub fn source(&self) -> &UsageSource
Sourcepub fn record(
&mut self,
purpose: LlmCallPurpose,
model: ModelIdentity,
tokens: TokenUsage,
) -> SessionUsageEvent
pub fn record( &mut self, purpose: LlmCallPurpose, model: ModelIdentity, tokens: TokenUsage, ) -> SessionUsageEvent
Record one of this agent’s own calls, priced from the model’s catalog entry.
Sourcepub fn record_child(
&mut self,
task_id: &str,
child: SessionUsageEvent,
) -> SessionUsageEvent
pub fn record_child( &mut self, task_id: &str, child: SessionUsageEvent, ) -> SessionUsageEvent
Fold a sub-agent’s sample into these totals. The child’s model and cost stand; its lineage is filled in when the child did not know it.
Trait Implementations§
Source§impl Clone for SessionUsageTracker
impl Clone for SessionUsageTracker
Source§fn clone(&self) -> SessionUsageTracker
fn clone(&self) -> SessionUsageTracker
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SessionUsageTracker
impl RefUnwindSafe for SessionUsageTracker
impl Send for SessionUsageTracker
impl Sync for SessionUsageTracker
impl Unpin for SessionUsageTracker
impl UnsafeUnpin for SessionUsageTracker
impl UnwindSafe for SessionUsageTracker
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
Source§fn into_maybe_undefined(self) -> MaybeUndefined<T>
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Converts this value into a three-state builder argument.
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
Source§fn into_option(self) -> Option<T>
fn into_option(self) -> Option<T>
Converts this value into an optional builder argument.