Skip to main content

llm/usage/
context_usage.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use super::Tokens;
5
6/// One agent's context window after its most recent LLM call.
7#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
8#[serde(default)]
9pub struct ContextUsage {
10    /// `input_tokens` as a fraction of `context_limit`, when the limit is known.
11    pub usage_ratio: Option<f64>,
12    pub context_limit: Option<Tokens>,
13    /// Input tokens on the most recent call, i.e. the current size of the context.
14    pub input_tokens: Tokens,
15}