pub struct ContextUsage {
pub model: String,
pub total_tokens: u64,
pub raw_max_tokens: u64,
pub percentage: u64,
pub over_limit: Option<ContextOverLimit>,
pub categories: Vec<ContextCategory>,
pub mcp_tools: Vec<ContextMcpTool>,
pub memory_files: Vec<ContextMemoryFile>,
pub agents: Vec<ContextAgent>,
pub skills: Option<Vec<ContextSkill>>,
}Expand description
Structured twin of the /context report, carried as
AssistantMessage::context_usage — the data a client needs to render
the context-usage card without parsing the markdown table. Evolves
additively; a breaking reshape would ship as a sibling field.
Fields§
§model: StringMain-loop model the usage was computed for.
total_tokens: u64Estimated tokens in use, unclamped — may exceed raw_max_tokens when
over limit.
raw_max_tokens: u64The window usage is measured against: the resolved autocompact window — the model’s believed limit, or a smaller compaction-policy window.
percentage: u64Rounded total_tokens / raw_max_tokens, 0–100+.
over_limit: Option<ContextOverLimit>Present when total_tokens exceeds raw_max_tokens.
categories: Vec<ContextCategory>Usage-by-category rows (Messages, System prompt, …).
mcp_tools: Vec<ContextMcpTool>Per-tool token contributions of MCP tools.
memory_files: Vec<ContextMemoryFile>Per-file token contributions of memory files.
agents: Vec<ContextAgent>Per-agent token contributions of agent definitions.
skills: Option<Vec<ContextSkill>>Per-skill token contributions. Omitted when no skills contribute.
Trait Implementations§
Source§impl Clone for ContextUsage
impl Clone for ContextUsage
Source§fn clone(&self) -> ContextUsage
fn clone(&self) -> ContextUsage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more