This commit is contained in:
Ahmed Ibrahim
2025-10-24 10:08:47 -07:00
parent 79c628a823
commit 6ffbd0d4e3
2 changed files with 3 additions and 1 deletions

View File

@@ -146,7 +146,7 @@ impl ConversationHistory {
}
}
let prior_total = info.total_token_usage.total_tokens;
let prior_total = info.last_token_usage.total_tokens;
let combined_tokens = prior_total.saturating_add(input_tokens);
let threshold = context_window * 95 / 100;
if combined_tokens > threshold {

View File

@@ -577,7 +577,9 @@ pub struct TokenUsage {
#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema, TS)]
pub struct TokenUsageInfo {
/// The total token usage for the session. accumulated from all turns.
pub total_token_usage: TokenUsage,
/// The token usage for the last turn. Received from the API.
pub last_token_usage: TokenUsage,
#[ts(type = "number | null")]
pub model_context_window: Option<i64>,