pub struct ContextUsage {Show 14 fields
pub model: String,
pub window: usize,
pub reserved_output: usize,
pub auto_compact_threshold: usize,
pub used_tokens: usize,
pub last_request_tokens: Option<usize>,
pub summary_tokens: usize,
pub user_tokens: usize,
pub assistant_tokens: usize,
pub tool_call_tokens: usize,
pub tool_result_tokens: usize,
pub image_tokens: usize,
pub messages: usize,
pub prompt_cache_ttl: Option<Duration>,
}Expand description
How full a session’s context is (estimates; see MicroClaw::context_usage).
Fields§
§model: String§window: usizeThe model’s context window (tokens).
reserved_output: usizeTokens kept free for the reply.
auto_compact_threshold: usizeTokens at which automatic compaction starts (0: disabled).
used_tokens: usizeTokens the next request carries (measured when available).
last_request_tokens: Option<usize>Input tokens of the last request, as reported by the provider.
summary_tokens: usize§user_tokens: usize§assistant_tokens: usize§tool_call_tokens: usize§tool_result_tokens: usize§image_tokens: usize§messages: usize§prompt_cache_ttl: Option<Duration>How long the provider keeps this session’s prompt cache, when the
engine marks cache breakpoints for it (Anthropic); None otherwise.
Implementations§
Source§impl ContextUsage
impl ContextUsage
Sourcepub fn percent_used(&self) -> u8
pub fn percent_used(&self) -> u8
Share of the usable window (window minus the output reserve) in use.
Trait Implementations§
Source§impl Clone for ContextUsage
impl Clone for ContextUsage
Source§impl Debug for ContextUsage
impl Debug for ContextUsage
Source§impl Default for ContextUsage
impl Default for ContextUsage
impl Eq for ContextUsage
Source§impl PartialEq for ContextUsage
impl PartialEq for ContextUsage
impl StructuralPartialEq for ContextUsage
Auto Trait Implementations§
impl Forget for ContextUsage
impl Freeze for ContextUsage
impl Move 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
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<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
Compare self to
key and return true if they are equal.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
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
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> IntoMaybeUndefined<T> for T
impl<T> IntoMaybeUndefined<T> for T
fn into_maybe_undefined(self) -> MaybeUndefined<T>
Source§impl<T> IntoOption<T> for T
impl<T> IntoOption<T> for T
fn into_option(self) -> Option<T>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request