Description
In a long session using the built-in anthropic provider with extended
thinking, every request eventually fails with:
Anthropic API error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.660.content.0.thinking.cache_control: Extra inputs are not
permitted"},"request_id":"req_011CfLwdUDbS6AEZanP2zGVJ"}
Anthropic permits cache_control on text/tool_use/tool_result/image/document
blocks but NOT on thinking or redacted_thinking. OpenCode's rolling
conversation cache breakpoint lands on an assistant message whose first/last
content block is a thinking block once the history is long enough. Because the
chosen breakpoint index is stable, the session is then permanently poisoned:
every subsequent turn rebuilds the same invalid request and 400s. The only
user-visible recovery is abandoning the session.
Short sessions never hit it, which makes it look intermittent.
Steps to reproduce
- Built-in
anthropic provider (API key auth), extended-thinking model.
- Run a session long enough (~hundreds of messages) that the cache
breakpoint's stable message is an assistant turn whose block 0 is
thinking.
- Every turn from then on fails with the 400 above; retrying does not help.
Expected
The breakpoint picker should walk past messages whose candidate block is a
thinking/redacted_thinking block and stamp the nearest legally cacheable
block instead (same approach as microsoft/amplifier-module-provider-anthropic
PR #99, which fixed the identical failure shape).
Environment
Description
In a long session using the built-in
anthropicprovider with extendedthinking, every request eventually fails with:
Anthropic permits
cache_controlon text/tool_use/tool_result/image/documentblocks but NOT on
thinkingorredacted_thinking. OpenCode's rollingconversation cache breakpoint lands on an assistant message whose first/last
content block is a thinking block once the history is long enough. Because the
chosen breakpoint index is stable, the session is then permanently poisoned:
every subsequent turn rebuilds the same invalid request and 400s. The only
user-visible recovery is abandoning the session.
Short sessions never hit it, which makes it look intermittent.
Steps to reproduce
anthropicprovider (API key auth), extended-thinking model.breakpoint's stable message is an assistant turn whose block 0 is
thinking.Expected
The breakpoint picker should walk past messages whose candidate block is a
thinking/redacted_thinkingblock and stamp the nearest legally cacheableblock instead (same approach as microsoft/amplifier-module-provider-anthropic
PR #99, which fixed the identical failure shape).
Environment
anthropicprovider,apiKeyauth("Cache point cannot be inserted after reasoning block").