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.

Claude APIHosted AI APIsLLM model/API behavior driftanthropic_migrate

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