LLM model/API behavior drift
Anthropic Claude API token counting API messages count tokens model-specific tokenizer context window docs
Local heuristic says the prompt fits, but the provider rejects or truncates it after model migration.
Agent Quick Fix
Repair against the current Claude API contract, then keep the change narrow and source-backed.
Product: Claude API
Current-contract area: Tokenizer change breaks preflight token budget
Likely root cause: Local heuristic says the prompt fits, but the provider rejects or truncates it after model migration.
Repair direction: Verifier checks current model ID, accepted payload, structured output/tool parsing, and behavior under retries.
Symptom
Local heuristic says the prompt fits, but the provider rejects or truncates it after model migration.
Why This Happens
SDK types may still accept fields that the selected hosted model rejects; model retirement, tokenizer, thinking, and tool behavior are external and fast-moving.
Common Wrong Fixes
- Changing local code without checking the current external contract.
- Retrying the same install, build, or API call with no version/source change.
- Applying a broad unsafe bypass when a narrow compatibility fix is available.
Codex Search Keywords
These are the search terms observed in a neutral Codex validation run for this failure shape.
Anthropic Claude API token counting API messages count tokens model-specific tokenizer context window docs
site:docs.anthropic.com count tokens messages API Claude token counting
https://docs.anthropic.com/en/docs/build-with-claude/token-counting
https://platform.claude.com/docs/en/build-with-claude/context-windows
Source Trail
- Claude model migration guide: https://platform.claude.com/docs/en/about-claude/models/migration-guide
- Official reference opened by Codex: https://docs.anthropic.com/en/docs/build-with-claude/token-counting
- Official reference opened by Codex: https://platform.claude.com/docs/en/build-with-claude/context-windows