Skip to content

[FEATURE]: allow disabling cache_control on tool definitions for Anthropic-compatible endpoints #58799

Open

Description

@TheBrain0110

Describe the enhancement you want to request

Some Anthropic-compatible endpoints accept prompt-cache markers on system and message content but reject cache_control on tool definitions with HTTP 400.

Repro shape: ordinary prompts work fine, but as soon as OpenCode's automatic cache policy marks the last tool definition, the request fails with a 400. Suppressing only the tool-definition marker restores both the streaming response and the tool-call loop, while system and message caching keeps working.

The current workaround is cache: "none", which disables all automatic cache placement — including the system and message cache sites these endpoints do support. That is a bigger loss than necessary.

What I would like: a model-level compatibility option (for example compatibility.supportsToolCacheControl) that lets a model declare that its endpoint rejects cache_control on tool definitions. When set to false:

  • automatic cache placement skips tool definitions
  • manually supplied tool cache hints are dropped when lowering to the Anthropic Messages wire format
  • tool hints are excluded from the four-breakpoint budget, so system and message markers keep the available capacity

When the option is omitted it should default to the existing behavior, so Anthropic and other providers are unaffected. This is generic compatibility metadata — it should not special-case any particular provider ID.

I have a working implementation and tests ready, and can open a PR.

Activity

  1. opencode-agent commented on Oct 24, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed write-up, @TheBrain0110!

    To restate the request: add a model-level compatibility option (for example compatibility.supportsToolCacheControl: false). It would let Anthropic-compatible endpoints that reject cache_control on tool definitions keep their system and message cache breakpoints. Today the only workaround is cache: "none", which turns off all automatic cache placement. Maintainers will consider it.

    Your PR #58793 was closed automatically only because it targeted the old v2 branch. If you want to go ahead, you can open a new PR from the same branch into dev and add Closes #58799 to its description so it is linked to this issue.

    Related issues:

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