LLM model/API behavior drift

Anthropic Claude API assistant prefill JSON prefix 400 migrated model assistant message must not end with trailing whitespace

A JSON-prefix prompting pattern begins returning 400 on the migrated model.

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: Assistant-prefill continuation rejected
Likely root cause: A JSON-prefix prompting pattern begins returning 400 on the migrated model.
Repair direction: Verifier checks current model ID, accepted payload, structured output/tool parsing, and behavior under retries.

Symptom

A JSON-prefix prompting pattern begins returning 400 on the migrated model.

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 assistant prefill JSON prefix 400 migrated model assistant message must not end with trailing whitespace
Claude API 400 prefill assistant message JSON prefix
site:docs.anthropic.com assistant prefill Claude Messages API
Anthropic docs prefill Claude response assistant role
https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/prefill-claudes-response
site:platform.claude.com/docs prefill response assistant message
https://platform.claude.com/docs/llms.txt
"assistant" "prefill" "400" "Claude"
site:docs.anthropic.com "prefill" "extended thinking"
Claude extended thinking prefill not supported
https://docs.anthropic.com/en/api/messages
https://raw.githubusercontent.com/anthropics/anthropic-sdk-typescript/main/README.md
platform.claude.com/docs/en/api/messages.md
https://platform.claude.com/docs/en/docs/test-and-evaluate/strengthen-guardrails/increase-consistency

Source Trail

GitHub source file/reference: