Model Selection and Optimization
Generation Mechanics and Model Options
Exam objective: Applying an understanding of tokens, context windows, sampling and non-determinism, and model options such as adaptive thinking and effort levels to predict, explain, and control an observed behavior.
What the exam tests
Whether you can predict, explain and control what a request does: why output was truncated, why two identical calls differ, why a bill or a context window grew, and which setting changes the behavior. Expect a symptom plus a request or usage log.
Key rules
Tokens. Models read and write tokens, and characters per token vary by model and language. Claude 4.7 and later use a newer tokenizer that produces about 30 percent more tokens than earlier models. Count with the model you plan to use. The token counting endpoint is free, rate limited and gives an estimate.
Context window. It holds the system prompt, all messages, tool definitions and the generated output, thinking included. Cached tokens still occupy it. Input alone over the limit is a 400. On Claude 4.5 and newer, input plus max_tokens over the limit is accepted, and generation that hits the window stops with model_context_window_exceeded. More context is not automatically better: recall degrades as it grows.
Non-determinism. Identical inputs can give different outputs, even at temperature 0. Test properties, not exact strings.
Sampling parameters. Claude Opus 4.7 and later Opus, Sonnet 5 and 5.5, Haiku 5.5 and the Fable and Mythos models reject non-default temperature, top_p and top_k with a 400, thinking or not. From API version 2026-10-21, any value is rejected on every model.
Thinking. In adaptive mode Claude decides per request whether and how much to think. Thinking is billed as output and counts toward max_tokens, even when display is "omitted" and the text is empty. usage.output_tokens_details.thinking_tokens shows its share. Manual budget_tokens is legacy: deprecated on 4.6, rejected on 4.7 and later.
Configuration differs by model. Opus 5.5 and the Fable and Mythos 5.x models cannot turn thinking off. Sonnet 5.5 rejects "disabled" and takes "between_tools" (effort high or below) to skip up-front thinking. Opus 5 and Haiku 5.5 accept "disabled" only at high or below.
Effort. output_config.effort takes low, medium, high, xhigh or max (availability varies). It shapes text, tool calls and thinking. It is guidance; max_tokens is the hard cap per request. Opus 5.5 and Haiku 5.5 default to medium, other models to high.
{"model": "claude-sonnet-5-5", "max_tokens": 16000,
"thinking": {"type": "adaptive", "display": "summarized"},
"output_config": {"effort": "medium"},
"messages": [{"role": "user", "content": "..."}]}
History. Opus 4.5+, Sonnet 4.6+, Haiku 5.5 and Fable and Mythos models keep earlier thinking blocks in context and bill them as input. Earlier models strip them. Return blocks unmodified, especially in tool loops.
Caching. Changing the thinking configuration or top-level effort between turns can invalidate the cache. Hold them constant, or use per-message effort where supported.
Traps
- Reading
content[0].text: a thinking block may come first, or be absent. - Expecting
display: "omitted"to cut cost. It only speeds up the first streamed text. - Treating effort as a token limit, or
max_tokensas a way to make the model think less. - Reusing token counts or effort settings from another model. Levels are calibrated per model.
- Assuming an empty
thinkingfield means no reasoning happened. - Assuming a bigger
max_tokensfixes an input that is already too long.
Decide quickly
| Situation | Choice | Why |
|---|---|---|
stop_reason: "max_tokens", reasoning needed | Raise max_tokens | Room for thinking and text |
| Same stop, task was over-thought | Lower effort | Less thinking |
| Cheaper, faster responses | Lower effort first | Scales the whole response |
| Hard spend limit per request | max_tokens | Strict cap |
| Reasoning too shallow | Raise effort | Primary thinking lever |
| Need to see reasoning | display: "summarized" | Default is empty on many models |
| Will the prompt fit? | Count tokens first | Estimate before sending |
| Vary depth inside a cached chat | Per-message effort | Keeps the cached prefix |
| Output varies between runs | Evals on properties | Determinism is not available |