pub struct ContextAnalysis {
pub tool_request_tokens: HashMap<String, usize>,
pub tool_result_tokens: HashMap<String, usize>,
pub human_tokens: usize,
pub assistant_tokens: usize,
pub duplicate_reads: HashMap<PathBuf, DuplicateRead>,
pub total: usize,
}Expand description
Per-tool and per-role token breakdown of a conversation context.
Fields§
§tool_request_tokens: HashMap<String, usize>Tokens in tool request blocks (assistant → tool_use), keyed by tool name.
tool_result_tokens: HashMap<String, usize>Tokens in tool result blocks (tool → result), keyed by tool name.
human_tokens: usizeTokens in human/user messages (excluding tool results).
assistant_tokens: usizeTokens in assistant messages (excluding tool requests).
duplicate_reads: HashMap<PathBuf, DuplicateRead>Files read more than once, with count and estimated wasted tokens.
total: usizeTotal estimated tokens across all messages.
Implementations§
Source§impl ContextAnalysis
impl ContextAnalysis
Sourcepub fn total_tool_result_tokens(&self) -> usize
pub fn total_tool_result_tokens(&self) -> usize
Total tokens consumed by all tool results.
Sourcepub fn total_tool_request_tokens(&self) -> usize
pub fn total_tool_request_tokens(&self) -> usize
Total tokens consumed by all tool requests.
Sourcepub fn total_duplicate_waste(&self) -> usize
pub fn total_duplicate_waste(&self) -> usize
Total tokens wasted by duplicate file reads.
Sourcepub fn tool_result_percent(&self) -> usize
pub fn tool_result_percent(&self) -> usize
Percentage of total context consumed by tool results.
Sourcepub fn duplicate_read_percent(&self) -> usize
pub fn duplicate_read_percent(&self) -> usize
Percentage of total context consumed by duplicate reads.
Trait Implementations§
Source§impl Clone for ContextAnalysis
impl Clone for ContextAnalysis
Source§fn clone(&self) -> ContextAnalysis
fn clone(&self) -> ContextAnalysis
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextAnalysis
impl Debug for ContextAnalysis
Source§impl Default for ContextAnalysis
impl Default for ContextAnalysis
Source§fn default() -> ContextAnalysis
fn default() -> ContextAnalysis
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ContextAnalysis
impl RefUnwindSafe for ContextAnalysis
impl Send for ContextAnalysis
impl Sync for ContextAnalysis
impl Unpin for ContextAnalysis
impl UnsafeUnpin for ContextAnalysis
impl UnwindSafe for ContextAnalysis
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
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more