{"record":{"id":"be1d8a432b7f7016","repo":"zed-industries/zed","slug":"model-hit-maximum-token-limit","errorCode":null,"errorMessage":"Model hit maximum token limit","messagePattern":"Model hit maximum token limit","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/eval_cli/src/main.rs","lineNumber":860,"sourceCode":"    } else {\n        futures::future::Either::Right(futures::future::pending::<()>())\n    };\n\n    let sigterm_future = {\n        let executor = cx.background_executor().clone();\n        async move {\n            while !TERMINATED.load(Ordering::Relaxed) {\n                executor.timer(Duration::from_millis(100)).await;\n            }\n        }\n    };\n\n    let outcome = select_biased! {\n        result = send_future.fuse() => match result {\n            Ok(Some(response)) => {\n                eprintln!(\"[eval-cli] stopped: {:?}\", response.stop_reason);\n                if response.stop_reason == acp::StopReason::MaxTokens {\n                    Err(anyhow::anyhow!(\"Model hit maximum token limit\"))\n                } else {\n                    Ok(AgentOutcome::Completed)\n                }\n            }\n            Ok(None) => {\n                eprintln!(\"[eval-cli] completed (no response)\");\n                Ok(AgentOutcome::Completed)\n            }\n            Err(e) => Err(e).context(\"agent run failed\"),\n        },\n        _ = sigterm_future.fuse() => {\n            eprintln!(\"[eval-cli] received SIGTERM, cancelling...\");\n            acp_thread.update(cx, |t: &mut acp_thread::AcpThread, cx| t.cancel(cx)).await;\n            Ok(AgentOutcome::Interrupted)\n        },\n        _ = timeout_future.fuse() => {\n            acp_thread.update(cx, |t: &mut acp_thread::AcpThread, cx| t.cancel(cx)).await;\n            Ok(AgentOutcome::Timeout { seconds: timeout.unwrap_or(0) })","sourceCodeStart":842,"sourceCodeEnd":878,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/eval_cli/src/main.rs#L842-L878","documentation":"The agent run finished because the model's response hit its maximum token output limit (stop reason max_tokens, detected in the select_biased! outcome handling). This is a run-terminating condition reported as an error rather than a successful AgentOutcome, distinguishing token-limit stops from normal completion.","triggerScenarios":"Thrown at crates/eval_cli/src/main.rs:860 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Raise the model's max output tokens setting/limit for the run","Split the instruction into smaller tasks so a single response fits the limit","Enable continuation handling that resumes the request instead of treating max_tokens as fatal"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}