New stop reason model_context_window_exceeded
The Messages API can now return `stop_reason: "model_context_window_exceeded"`, letting you ask for the maximum possible output tokens without first computing how large your input is.
What does this mean for me?
Action needed
Engineering leadership
Cost, risk, timeline, team impact Worth knowingSmall robustness change: teams can stop pre-computing safe output ceilings. The only risk is code that exhaustively matches on stop reasons.
Engineer
What to change, what breaks, what to test Action neededAdd a branch for `stop_reason: "model_context_window_exceeded"` anywhere you switch on `stop_reason`, and treat it like `max_tokens` — a truncated but valid response, not an error. You can now request a large `max_tokens` without computing input size first.
General consumer
Using the Claude apps, not the API No impactNothing to do — this is an API-only change.
Previously, requesting more max_tokens than the remaining context allowed produced a validation error, so callers had to count input tokens and compute a safe ceiling. With this stop reason, you can request the maximum and let the model stop when it hits the window, reporting why.
The flip side is that any code that switches on stop_reason needs a branch for a value it has never seen. Treat it like max_tokens: the response is complete-as-far-as-it-goes, not an error.
This is an additive enum value, not a removal, so exhaustive-match handling is the only thing likely to break.
API surface
| Parameter | Change | Breaking | Models |
|---|---|---|---|
stop_reason | added | no |