From 8e9746b19d20539ab3fbce5d69a4e0cd09b27305 Mon Sep 17 00:00:00 2001 From: Keyan Zhang <2268452+keyz@users.noreply.github.com> Date: Wed, 18 Nov 2026 22:23:52 +0000 Subject: [PATCH] Remove the 4,000-byte prompt limit for `thread/sample` (#62378) ## What changed Allow prompts longer than 4,000 bytes to pass `thread/sample` request validation. Both `expectedTurnId` and `prompt` must still be nonblank. GitOrigin-RevId: 59b97d351e2a02378b83aa9f2d4e649dd57169af --- codex-rs/app-server/src/thread_sample.rs | 13 ++++--------- codex-rs/app-server/tests/suite/v2/thread_sample.rs | 8 +------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/codex-rs/app-server/src/thread_sample.rs b/codex-rs/app-server/src/thread_sample.rs index 289190f7ae..a170ede9d3 100644 --- a/codex-rs/app-server/src/thread_sample.rs +++ b/codex-rs/app-server/src/thread_sample.rs @@ -55,8 +55,6 @@ use tokio_util::sync::CancellationToken; use tokio_util::task::TaskTracker; const SAMPLE_TIMEOUT: Duration = Duration::from_secs(30); -// Bytes conservatively bound tokens, including for byte-fallback tokenizers. -const MAX_PROMPT_BYTES: usize = 4_000; const MAX_OUTPUT_BYTES: usize = 64 * 1024; const THREAD_SNAPSHOT_NOTE: &str = concat!( "\nThis snapshot is a copy of the source thread’s history taken while its turn was still running. ", @@ -85,13 +83,10 @@ pub(crate) async fn generate_sample( rpc_gate: Arc, ) -> SampleResult { let deadline = Instant::now() + SAMPLE_TIMEOUT; - if task.params.expected_turn_id.trim().is_empty() - || task.params.prompt.trim().is_empty() - || task.params.prompt.len() > MAX_PROMPT_BYTES - { - return Err(invalid_request(format!( - "thread/sample requires expectedTurnId and a prompt of at most {MAX_PROMPT_BYTES} bytes", - ))); + if task.params.expected_turn_id.trim().is_empty() || task.params.prompt.trim().is_empty() { + return Err(invalid_request( + "thread/sample requires a nonblank expectedTurnId and prompt", + )); } let (sender, receiver) = oneshot::channel(); let originator = AuthStorageOriginator::current(); diff --git a/codex-rs/app-server/tests/suite/v2/thread_sample.rs b/codex-rs/app-server/tests/suite/v2/thread_sample.rs index e3c40aa3e1..b62fd44d6d 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_sample.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_sample.rs @@ -1319,13 +1319,7 @@ async fn sample_rejects_invalid_sources_and_prompts() -> Result<()> { "Predict".to_string(), "latest finished turn", ), - (parent.clone(), turn.clone(), String::new(), "prompt"), - ( - parent.clone(), - turn.clone(), - "x".repeat(4_001), - "at most 4000 bytes", - ), + (parent, turn, String::new(), "prompt"), ] { let id = client .send_raw_request(