Repository navigation
fix(ai): allow disabling cache control on tools - #58793
TheBrain0110 wants to merge 1 commit into
Conversation
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 72 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
Thanks for putting this together, @TheBrain0110! The Please open it again with |
What
Add a model compatibility option,
supportsToolCacheControl, that allows Anthropic-compatible endpoints to disablecache_controlon tool definitions while retaining cache markers on supported system and message content.Why
Some Anthropic-compatible endpoints accept prompt-cache markers on
systemand message content but rejecttools[].cache_controlwith HTTP 400. The existingcache: "none"policy is too broad because it disables all automatic cache placement, including cache sites those endpoints support.This was reproduced against an Anthropic-compatible governed proxy: ordinary prompts worked until OpenCode's automatic cache policy marked a tool definition. Suppressing only tool-definition markers restored both streaming and tool-call loops while preserving system/message caching.
How
supportsToolCacheControlmodel compatibility metadata; omitted defaults to the existing behavior (true).false.Verification
bun test test/cache-policy.test.tsfrompackages/ai: 18 passed, 0 failedbun run --cwd packages/schema typecheck: passedbun run --cwd packages/ai typecheck: passedbun run --cwd packages/core typecheck: passedgit diff --check: passedv2branch.ANTHROPIC_COMPAT_OKproof.txt:tool-proof-73OPENAI_REGRESSION_OKNotes
The default remains unchanged for Anthropic and other providers. This is generic compatibility metadata rather than a check for any private provider ID.