pub struct ContextUsage {
pub model: String,
pub messages: usize,
pub message_tokens: u64,
pub tool_count: usize,
pub tool_schema_tokens: u64,
pub request_tokens: u64,
pub projected_tokens: u64,
pub response_reserve_tokens: u64,
pub context_limit: Option<u64>,
pub remaining_tokens: u64,
pub used_pct: u32,
pub fits: bool,
}Expand description
BP-4 (catalog:109 “Context-usage introspection”): the live
context-window accounting Agent::context_usage reports — cc’s
/context grid and cx’s /status + get_context_remaining in one
shape, over the numbers resume --dry-run’s preflight already computes.
Every token figure is the SAME estimate the context guard enforces
(crate::tokens), so what this reports and what refuses an oversized
turn can never disagree.
Fields§
§model: StringThe model the accounting is against.
messages: usizeMessages in the projected request view (reduction stubs included).
message_tokens: u64Estimated tokens for those messages.
tool_count: usizeTools advertised on the next request.
tool_schema_tokens: u64Estimated tokens for the serialized tool-schema array — a real part of the wire request, and the half a message-only count misses.
request_tokens: u64message_tokens + tool_schema_tokens.
projected_tokens: u64request_tokens with the guard’s safety margin applied — the figure
the context guard actually compares.
response_reserve_tokens: u64Headroom the guard reserves for the model’s own reply.
context_limit: Option<u64>The model’s context window, when known.
remaining_tokens: u64Tokens still available after the reply reserve, 0 when unknown.
used_pct: u32projected_tokens as a whole percentage of the window (rounded),
0 when the window is unknown. An integer so this whole struct
stays Eq-comparable on the frontend wire.
fits: boolWhether the next request would pass the context guard.
Implementations§
Source§impl ContextUsage
impl ContextUsage
Sourcepub fn summary_line(&self) -> String
pub fn summary_line(&self) -> String
One human line, the shape a /context command prints.
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 moreSource§impl Debug for ContextUsage
impl Debug for ContextUsage
Source§impl<'de> Deserialize<'de> for ContextUsage
impl<'de> Deserialize<'de> for ContextUsage
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 ContextUsage
Source§impl PartialEq for ContextUsage
impl PartialEq for ContextUsage
Source§impl Serialize for ContextUsage
impl Serialize for ContextUsage
impl StructuralPartialEq for ContextUsage
Auto Trait Implementations§
impl Freeze for ContextUsage
impl RefUnwindSafe for ContextUsage
impl Send for ContextUsage
impl Sync for ContextUsage
impl Unpin for ContextUsage
impl UnsafeUnpin for ContextUsage
impl UnwindSafe for ContextUsage
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§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.