pub trait TokenUsageContributor: Send + Sync {
// Provided method
fn on_token_usage<'a>(
&'a self,
_session_store: &'a ExtensionData,
_thread_store: &'a ExtensionData,
_turn_store: &'a ExtensionData,
_token_usage: &'a TokenUsageInfo,
) -> ExtensionFuture<'a, ()> { ... }
}Expand description
Contributor for token usage checkpoints reported by the model provider.
Implementations should keep this callback cheap. The host calls it after updating cached token usage and before emitting the corresponding client token-count notification.
Provided Methods§
Sourcefn on_token_usage<'a>(
&'a self,
_session_store: &'a ExtensionData,
_thread_store: &'a ExtensionData,
_turn_store: &'a ExtensionData,
_token_usage: &'a TokenUsageInfo,
) -> ExtensionFuture<'a, ()>
fn on_token_usage<'a>( &'a self, _session_store: &'a ExtensionData, _thread_store: &'a ExtensionData, _turn_store: &'a ExtensionData, _token_usage: &'a TokenUsageInfo, ) -> ExtensionFuture<'a, ()>
Called each time the host records token usage from a model response.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".