{"record":{"id":"4abb2e4dae71a1f4","repo":"openai/codex","slug":"queued-user-input-exceeds-the-maximum-length-of-m","errorCode":null,"errorMessage":"queued user input exceeds the maximum length of {MAX_USER_INPUT_TEXT_CHARS} characters ({actual_chars} provided)","messagePattern":"queued user input exceeds the maximum length of (.+?) characters \\((.+?) provided\\)","errorType":"validation","errorClass":"QueueServiceError","httpStatus":null,"severity":"error","filePath":"codex-rs/ext/queue/src/service.rs","lineNumber":58,"sourceCode":"#[derive(Clone, Debug, PartialEq)]\npub struct QueuedItem {\n    pub id: String,\n    pub input: TurnInput,\n}\n\n#[derive(Debug, Error)]\npub enum QueueServiceError {\n    #[error(\"queue storage failed: {0}\")]\n    Storage(#[from] ThreadStoreError),\n    #[error(\"queued submission payload is invalid: {0}\")]\n    InvalidPayload(#[from] serde_json::Error),\n    #[error(\"local queued attachment is invalid: {0}\")]\n    InvalidAttachment(#[from] std::io::Error),\n    #[error(\"Core failed to submit queued user message: {0}\")]\n    CoreSubmissionError(#[from] CodexErr),\n    #[error(\"only user input can be added to the user-message queue\")]\n    InvalidInput,\n    #[error(\n        \"queued user input exceeds the maximum length of {MAX_USER_INPUT_TEXT_CHARS} characters ({actual_chars} provided)\"\n    )]\n    InputTooLarge { actual_chars: usize },\n}\n\n#[derive(Clone)]\npub struct QueuedItemService {\n    queue: Arc<dyn QueueStore>,\n    thread_manager: Weak<ThreadManager>,\n    event_sink: Arc<dyn ExtensionEventSink>,\n    dispatch_locks: Arc<StdMutex<HashMap<ThreadId, Weak<Mutex<()>>>>>,\n    resumed_threads: Arc<StdMutex<HashSet<ThreadId>>>,\n}\n\nimpl QueuedItemService {\n    pub fn new(\n        queue: Arc<dyn QueueStore>,\n        thread_manager: Weak<ThreadManager>,","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/ext/queue/src/service.rs#L40-L76","documentation":"QueueServiceError::InputTooLarge { actual_chars } is returned by prepare_queued_user_input (codex-rs/ext/queue/src/service.rs:491-500) when the summed character count of all UserInput::Text items in the queued message exceeds MAX_USER_INPUT_TEXT_CHARS = 1 << 20 (1,048,576 chars; codex-rs/protocol/src/user_input.rs:9). The cap exists so one user message cannot monopolize the model context window. Only Text items count - images and audio are not included - and the limit is chars (chars().count()), not bytes.","triggerScenarios":"enqueue()/update() with a message whose Text items together exceed 1,048,576 characters: a giant pasted log, an inlined file, or base64 stuffed into text. Multi-part content is summed across all Text items, not checked per item.","commonSituations":"Pasting a large log or dataset into the composer while the thread is busy; automation that inlines whole files as message text; non-ASCII content where a byte-based client-side check (.len()) passes but the char-based queue check rejects.","solutions":["Split the content across several queued messages, each under the limit","Move oversized content into a file and reference or attach the path instead of inlining the text","Cap client-side using the same rule the queue uses: sum of text.chars().count() over Text items compared against MAX_USER_INPUT_TEXT_CHARS (1 << 20)","If a single blob legitimately exceeds about a million chars it also exceeds practical context - send it as a file attachment instead"],"exampleFix":"// before\nlet item = queue.enqueue(thread_id, input).await?; // InputTooLarge { actual_chars }\n\n// after\nuse codex_protocol::user_input::{UserInput, MAX_USER_INPUT_TEXT_CHARS};\nlet chars: usize = content.iter().filter_map(|i| match i {\n    UserInput::Text { text, .. } => Some(text.chars().count()),\n    _ => None,\n}).sum();\nif chars > MAX_USER_INPUT_TEXT_CHARS {\n    return Err(TooLong); // ask the user to trim, or split into multiple queued messages\n}\nlet item = queue.enqueue(thread_id, input).await?;","handlingStrategy":"validation","validationCode":"fn queued_text_chars(content: &[UserInput]) -> usize {\n    content.iter().filter_map(|item| match item {\n        UserInput::Text { text, .. } => Some(text.chars().count()),\n        _ => None,\n    }).sum()\n}\n// before enqueue:\nif queued_text_chars(&content) > MAX_USER_INPUT_TEXT_CHARS { /* split or reject */ }","typeGuard":null,"tryCatchPattern":"match err {\n    QueueServiceError::InputTooLarge { actual_chars } => {\n        // show: message is {actual_chars} chars; limit is 1_048_576\n    }\n    _ => {}\n}","preventionTips":["Count chars, not bytes - the limit is chars().count() summed over Text items only","Files belong in LocalImage/LocalAudio attachments or referenced paths, not inlined text","Show a live character counter as the composer approaches the cap"],"tags":["queue","input-validation","length-limit","rust"],"backgroundTag":"payload-too-large","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}