Skip to main content

EXPECTED_RESPONSE_TOKENS

Constant EXPECTED_RESPONSE_TOKENS 

Source
pub const EXPECTED_RESPONSE_TOKENS: u64 = 16_384;
Expand description

Visible output (text and tool calls) one round is expected to need on top of its thinking. The output reserve is this plus the thinking reserve, capped at the request’s max_tokens (ContextBudgetInputs::max_output_tokens).

Not the max_tokens ceiling itself (128k for Opus): Claude 4.5 and later accept a request whose input plus max_tokens exceeds the window and stop at the window with stop_reason: "model_context_window_exceeded" (https://platform.claude.com/docs/en/build-with-claude/context-windows#context-window-overflow-behavior), and for the earlier models that reject it the request builder clamps max_tokens to the room left (HelperMethods::fit_max_tokens_to_window). Reserving the full ceiling put hard capacity at ~31.5k on a 200k Opus window. 16k covers a large single-file write in one round; a round’s output becomes the next round’s input, so the following assessment sees it either way.