zed-industries/zed · error
Model hit maximum token limit
Error message
Model hit maximum token limit
What it means
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.
Source
Thrown at crates/eval_cli/src/main.rs:860
} else {
futures::future::Either::Right(futures::future::pending::<()>())
};
let sigterm_future = {
let executor = cx.background_executor().clone();
async move {
while !TERMINATED.load(Ordering::Relaxed) {
executor.timer(Duration::from_millis(100)).await;
}
}
};
let outcome = select_biased! {
result = send_future.fuse() => match result {
Ok(Some(response)) => {
eprintln!("[eval-cli] stopped: {:?}", response.stop_reason);
if response.stop_reason == acp::StopReason::MaxTokens {
Err(anyhow::anyhow!("Model hit maximum token limit"))
} else {
Ok(AgentOutcome::Completed)
}
}
Ok(None) => {
eprintln!("[eval-cli] completed (no response)");
Ok(AgentOutcome::Completed)
}
Err(e) => Err(e).context("agent run failed"),
},
_ = sigterm_future.fuse() => {
eprintln!("[eval-cli] received SIGTERM, cancelling...");
acp_thread.update(cx, |t: &mut acp_thread::AcpThread, cx| t.cancel(cx)).await;
Ok(AgentOutcome::Interrupted)
},
_ = timeout_future.fuse() => {
acp_thread.update(cx, |t: &mut acp_thread::AcpThread, cx| t.cancel(cx)).await;
Ok(AgentOutcome::Timeout { seconds: timeout.unwrap_or(0) })View on GitHub (pinned to f4178619ac)
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
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at crates/eval_cli/src/main.rs:860 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/be1d8a432b7f7016.
Report an issue: GitHub.