{"record":{"id":"117740c98d22d812","repo":"openai/codex","slug":"luna-response-exceeded-the-output-limit","errorCode":null,"errorMessage":"Luna response exceeded the output limit","messagePattern":"Luna response exceeded the output limit","errorType":"exception","errorClass":"LunaSamplerError","httpStatus":null,"severity":"warning","filePath":"codex-rs/ext/guardian-v2/src/async_scorer/sampler.rs","lineNumber":122,"sourceCode":"}\n\n/// Failures returned while connecting or sampling the Luna model.\n#[derive(Debug, Error)]\npub enum LunaSamplerError {\n    /// The thread's provider or scoped credentials could not be resolved.\n    #[error(\"could not resolve the Luna model provider: {0}\")]\n    Provider(#[source] CodexErr),\n    /// The Responses WebSocket could not be opened or streamed.\n    #[error(\"Luna Responses WebSocket failed: {0}\")]\n    Api(#[source] ApiError),\n    /// The provider's WebSocket connect deadline elapsed.\n    #[error(\"Luna Responses WebSocket connection timed out\")]\n    ConnectionTimeout,\n    /// The response did not contain an assistant text value.\n    #[error(\"Luna response did not contain assistant output\")]\n    MissingOutput,\n    /// The response exceeded the bounded output limit.\n    #[error(\"Luna response exceeded the output limit\")]\n    OutputTooLarge,\n    /// A newer classification replaced this request when the pool was full.\n    #[error(\"Luna request was superseded by a newer classification\")]\n    Superseded,\n}\n\nstruct PooledConnection {\n    connection: ResponsesWebsocketConnection,\n    // The bridge routes by thread ID, so each socket needs its own identity.\n    thread_id: String,\n    expires_at: Instant,\n    auth_changes: Option<tokio::sync::watch::Receiver<u64>>,\n}\n\nstruct ConnectionLease {\n    connection: PooledConnection,\n    idle_connections: Arc<Mutex<Vec<PooledConnection>>>,\n    _permit: OwnedSemaphorePermit,","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/ext/guardian-v2/src/async_scorer/sampler.rs#L104-L140","documentation":"Accumulated output or delta text exceeded MAX_OUTPUT_BYTES (8 KiB) mid-stream and the request aborted. The classifier is intentionally bounded because it must return a small JSON verdict. Non-retryable by design (retry_after_failure returns false for it).","triggerScenarios":"LunaSampler::sample where the model emits prose or a huge JSON object instead of a compact classification matching output_schema.","commonSituations":"Output schema with unbounded string fields (free-text rationale with no maxLength); model rambling instead of conforming to the strict schema.","solutions":["Tighten output_schema: bound every string (maxLength) and keep the verdict enum-only.","Keep large evidence in the input; restrict output to labels and scores.","Handle the error as 'no classification' rather than retrying — the sampler will not retry it.","Verify strict schema mode is actually applied to the request."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"match sampler.sample(request).await {\n    Err(LunaSamplerError::OutputTooLarge) => Classification::none(), // never retry\n    r => r?,\n}","preventionTips":["Bound every string in output_schema with maxLength.","Keep classification output to enums and scores; put prose in inputs.","Do not build retry loops around OutputTooLarge — it is deterministic."],"tags":["rust","output-limit","guardian","codex"],"backgroundTag":"response-size-limit-exceeded","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}