A couple weeks ago Anthropic shipped Claude 4.6 and removed support for assistant message prefilling. No deprecation period, just gone. If you were doing this:
messages=[
{"role": "user", "content": "Extract the name"},
{"role": "assistant", "content": '{"name": "'},
]
You now get a 400. Their migration guide says to use structured outputs or rewrite your prompts. If you have prefills scattered across a codebase, that's not a quick fix.
I wrote anthropic-compat to deal with it. It wraps the official SDK, catches the trailing assistant message, and converts it to a system prompt instruction telling the model to start its response with that exact text. The output is the same, model picks up right where the prefill left off.
Usage:
# before
import anthropic
# after
import anthropic_compat as anthropic
Everything else stays identical. Client, methods, exceptions, streaming, async, all passed through.
It also handles the output_format to output_config.format parameter rename they shipped in the same release, which is one less thing to grep for.
pip install anthropic-compat
https://github.com/ProAndMax/anthropic-compat
32 tests, no monkey patching, MIT licensed. Not saying structured outputs aren't the right long-term move, but if you just need your stuff to stop breaking right now this might help.
Top comments (0)