Account for encrypted reasoning for auto compaction (#7113)

- The total token used returned from the api doesn't account for the
reasoning items before the assistant message
- Account for those for auto compaction
- Add the encrypted reasoning effort in the common tests utils
- Add a test to make sure it works as expected
This commit is contained in:
Ahmed Ibrahim
2025-11-21 19:06:45 -08:00
committed by GitHub
parent 529eb4ff2a
commit b519267d05
9 changed files with 236 additions and 30 deletions

View File

@@ -2,6 +2,7 @@ use std::sync::Arc;
use std::sync::Mutex;
use anyhow::Result;
use base64::Engine;
use serde_json::Value;
use wiremock::BodyPrintLimit;
use wiremock::Match;
@@ -297,12 +298,18 @@ pub fn ev_reasoning_item(id: &str, summary: &[&str], raw_content: &[&str]) -> Va
.map(|text| serde_json::json!({"type": "summary_text", "text": text}))
.collect();
let overhead = "b".repeat(550);
let raw_content_joined = raw_content.join("");
let encrypted_content =
base64::engine::general_purpose::STANDARD.encode(overhead + raw_content_joined.as_str());
let mut event = serde_json::json!({
"type": "response.output_item.done",
"item": {
"type": "reasoning",
"id": id,
"summary": summary_entries,
"encrypted_content": encrypted_content,
}
});