pub struct ContextBreakdown {
pub system_prompt: u32,
pub rules: u32,
pub skills: u32,
pub subagents: u32,
pub tools: u32,
pub mcp_dynamic: u32,
pub conversation: u32,
pub overhead: u32,
}Expand description
Locally-estimated per-component token breakdown of the prompt sent to the provider.
Distinct from TokenUsage (which is the provider’s reported truth):
these are local chars/4 estimates, one bucket per logical segment of the
assembled prompt. The overhead bucket absorbs the difference between
the sum of the other buckets and the provider’s reported prompt_tokens
(chat-template wrapping, tool JSON envelope, message separators) so the
breakdown is honest about its estimation error rather than pretending
to be exact.
Recomputed every step: the static buckets (system_prompt, rules,
skills, subagents, tools, mcp_dynamic) change only on a /model
hot-swap or tool-registry change, while conversation grows with every
transcript mutation and overhead is derived from the provider’s
reported prompt_tokens after each step.
Fields§
§system_prompt: u32default_system_prompt + the six memory layers + any channel
append_system_prompt suffix.
rules: u32# Project context block: AGENTS.md + CLAUDE.md from
prepend_project_context.
skills: u32skill_index() output.
subagents: u32## Coordinator workflow + sub_agent usage note (only when
sub_agent_enabled).
tools: u32Eager tool specs that are NOT from MCP and NOT deferred.
mcp_dynamic: u32Tool specs that ARE MCP-sourced or deferred (the dynamic / discovered-tools bucket).
conversation: u32self.messages text content (transcript body).
overhead: u32Provider total - local sum (saturating to 0). Absorbs chat-template wrapping, tool JSON envelope, and message separators that the local estimate can’t reproduce.
Implementations§
Trait Implementations§
Source§impl Clone for ContextBreakdown
impl Clone for ContextBreakdown
impl Copy for ContextBreakdown
Source§impl Debug for ContextBreakdown
impl Debug for ContextBreakdown
Source§impl Default for ContextBreakdown
impl Default for ContextBreakdown
Source§impl<'de> Deserialize<'de> for ContextBreakdown
impl<'de> Deserialize<'de> for ContextBreakdown
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for ContextBreakdown
Source§impl PartialEq for ContextBreakdown
impl PartialEq for ContextBreakdown
Source§impl Serialize for ContextBreakdown
impl Serialize for ContextBreakdown
impl StructuralPartialEq for ContextBreakdown
Auto Trait Implementations§
impl Freeze for ContextBreakdown
impl RefUnwindSafe for ContextBreakdown
impl Send for ContextBreakdown
impl Sync for ContextBreakdown
impl Unpin for ContextBreakdown
impl UnsafeUnpin for ContextBreakdown
impl UnwindSafe for ContextBreakdown
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.