Skip to content

fix(ai): restore prompt caching for claude behind openai-compatible endpoints - #67708

Draft
neriousy wants to merge 2 commits into
devfrom
openai-compat-claude-cache
Draft

neriousy wants to merge 2 commits into
devfrom
openai-compat-claude-cache

Conversation

@neriousy

@neriousy neriousy commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Issue for this PR

Fixes #65400
Fixes #57199

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

two places broke prompt caching for claude behind openai-compatible endpoints

{ "compatibility": { "cacheFormat": "anthropic", "cacheControlAtMessageLevel": true } }

the new field is added to Model.Compatibility / Provider.Compatibility (schema) and LanguageModelCompatibility (ai), openapi + client + cli-rs types regenerated, and documented in models.mdx (english only)

no feature flag, it's a fix. the migration change only adds a field V1 already behaved like, and the new placement is opt-in

How did you verify your code works?

  • packages/core/test/config/normalization.test.ts: new test, V1 openai-compatible provider with claude models (by key and by id, plus interleaved) gets cacheFormat: "anthropic", non-claude and non-openai-compatible models don't. fails without the fix
  • packages/ai/test/provider/openai-compatible-chat.test.ts: new test, tool result as last message puts cache_control on the tool message with the opt-in and keeps the content-part position without it. fails without the fix
  • packages/core/test/config/provider.test.ts: extended the cache format test so cacheControlAtMessageLevel reaches the runtime model through ModelResolver
  • bun run script/test.ts test/config in core: 288 pass
  • bun run test in ai: 2350 pass, 2 fail (pdf.recorded.test.ts bedrock cassettes, only because my shell has AWS_REGION=us-west-2; pass with it unset)
  • bun typecheck in ai, core, schema, client, protocol, plus bun run typecheck:tsc in ai

Screenshots / recordings

n/a, request body + config only

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

This branch has not been deployed

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

Labels

None yet

Projects

None yet

1 participant