{"record":{"id":"0d3dedd9ebba1046","repo":"zed-industries/zed","slug":"output-token-limit-reached","errorCode":null,"errorMessage":"output token limit reached","messagePattern":"output token limit reached","errorType":"exception","errorClass":"MaxOutputTokensError","httpStatus":null,"severity":"error","filePath":"crates/acp_thread/src/acp_thread.rs","lineNumber":4144,"sourceCode":"\n                            let exceeded_max_output_tokens =\n                                this.token_usage.as_ref().is_some_and(|u| {\n                                    u.max_output_tokens\n                                        .is_some_and(|max| u.output_tokens >= max)\n                                });\n\n                            if exceeded_max_output_tokens {\n                                log::error!(\n                                    \"Max output tokens reached. Usage: {:?}\",\n                                    this.token_usage\n                                );\n                            } else {\n                                log::error!(\"Max tokens reached. Usage: {:?}\", this.token_usage);\n                            }\n                            if is_same_turn {\n                                this.cancel_pending_turn_entries(cx);\n                            }\n                            return Err(anyhow!(MaxOutputTokensError));\n                        }\n\n                        let canceled = matches!(r.stop_reason, acp::StopReason::Cancelled);\n                        if canceled && is_same_turn {\n                            this.cancel_pending_turn_entries(cx);\n                        }\n\n                        if !canceled {\n                            this.snapshot_completed_plan(cx);\n                        }\n\n                        // Handle refusal - distinguish between user prompt and tool call refusals\n                        if let acp::StopReason::Refusal = r.stop_reason {\n                            this.had_error = true;\n                            if let Some((user_msg_ix, _)) = this.last_user_message() {\n                                // Check if there's a completed tool call with results after the last user message\n                                // This indicates the refusal is in response to tool output, not the user's prompt\n                                let has_completed_tool_call_after_user_msg =","sourceCodeStart":4126,"sourceCodeEnd":4162,"githubUrl":"https://github.com/zed-industries/zed/blob/916fc2b8cb3a815cbef4a3b40e13081be72036b6/crates/acp_thread/src/acp_thread.rs#L4126-L4162","documentation":"AcpThread error fired when the model's cumulative output tokens for the turn reach the configured max_output_tokens limit. It is a deliberate guard so the thread stops generating instead of silently truncating; usage is logged before the error propagates.","triggerScenarios":"Thrown at crates/acp_thread/src/acp_thread.rs:3819 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Prompt the thread again to continue or have it summarize its work so far","Raise the max_output_tokens setting for the model if the task legitimately needs more output","Reduce the requested scope per turn (smaller steps, fewer files) so output fits the budget"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"916fc2b8cb3a815cbef4a3b40e13081be72036b6","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}