This commit is contained in:
Ahmed Ibrahim
2025-10-24 11:23:25 -07:00
parent 4e7089a8ab
commit 5d7983520b
2 changed files with 35 additions and 1 deletions

View File

@@ -118,6 +118,8 @@ impl ConversationHistory {
let Some(info) = &self.token_info else {
return Ok(());
};
// this will intentionally not check the context for the first turn before getting this information.
// it's acceptable tradeoff.
let Some(context_window) = info.model_context_window else {
return Ok(());
};

View File

@@ -1,11 +1,17 @@
use codex_core::protocol::EventMsg;
use codex_core::protocol::Op;
use codex_protocol::user_input::UserInput;
use core_test_support::responses;
use core_test_support::responses::ev_assistant_message;
use core_test_support::responses::ev_completed;
use core_test_support::responses::ev_response_created;
use core_test_support::responses::sse;
use core_test_support::responses::start_mock_server;
use core_test_support::test_codex::test_codex;
use core_test_support::wait_for_event_with_timeout;
use std::sync::Arc;
use std::time::Duration;
use wiremock::matchers::any;
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
async fn interrupt_tool_records_history_entries() {
@@ -14,8 +20,34 @@ async fn interrupt_tool_records_history_entries() {
let fixture = test_codex().build(&server).await.unwrap();
let codex = Arc::clone(&fixture.codex);
let wait_timeout = Duration::from_millis(100);
// First: normal message with a mocked assistant response
let first_response = sse(vec![
ev_response_created("resp-1"),
ev_assistant_message("msg-1", "ok"),
ev_completed("resp-1"),
]);
responses::mount_sse_once_match(&server, any(), first_response).await;
codex
.submit(Op::UserInput {
items: vec![UserInput::Text {
text: "hello world".into(),
}],
})
.await
.unwrap();
// Wait for the normal turn to complete before sending the oversized input
let turn_timeout = Duration::from_secs(2);
wait_for_event_with_timeout(
&codex,
|ev| matches!(ev, EventMsg::TaskComplete(_)),
turn_timeout,
)
.await;
// Then: 300k-token message should trigger validation error
let wait_timeout = Duration::from_millis(100);
let input_300_tokens = "token ".repeat(300_000);
codex