Skip to content

Cache breakpoint placed on a thinking block permanently 400s long Anthropic sessions (thinking.cache_control: Extra inputs are not permitted) #51141

Description

@anguslab-gh

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

  1. Built-in anthropic provider (API key auth), extended-thinking model.
  2. Run a session long enough (~hundreds of messages) that the cache
    breakpoint's stable message is an assistant turn whose block 0 is
    thinking.
  3. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions