pub trait TokenCounter: Send + Sync {
// Required method
fn count_tokens(&self, message: &AgentMessage) -> usize;
}Expand description
Pluggable token counting strategy.
Implement this trait to replace the built-in chars / 4 heuristic with
tiktoken, a provider-native tokenizer, or any other counting scheme.
Required Methods§
Sourcefn count_tokens(&self, message: &AgentMessage) -> usize
fn count_tokens(&self, message: &AgentMessage) -> usize
Return the estimated token count for a single message.