fix(models): preserve provider prompt cache boundaries#89460
Conversation
|
ClawSweeper status: review started. I am starting a fresh review of this pull request: fix(models): preserve provider prompt cache boundaries This is item 1/1 in the current shard. Shard 0/1. This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking. Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39bb4b585e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (split.dynamicSuffix) { | ||
| parts.push({ type: "text", text: split.dynamicSuffix }); |
There was a problem hiding this comment.
Keep OpenRouter wrapper from re-caching the suffix
For OpenRouter Anthropic models reached through the normal extra-params path, createOpenRouterSystemCacheWrapper is still applied afterward (src/agents/embedded-agent-runner/extra-params.ts:819), and its payload patch tags the last system content part with cache_control (src/agents/anthropic-payload-policy.ts:250-256). After this split, that last part is the dynamic suffix, so the wrapped OpenRouter route still caches the per-turn suffix that this change is trying to leave uncached; either skip the outer marker when the provider already handled Anthropic cache control or make that wrapper boundary-aware too.
Useful? React with 👍 / 👎.
|
Maintainer proof for exact head
Land-ready. |
Summary
Fixes #89386.
cache_control; the dynamic suffix stays uncached.Verification
node scripts/run-vitest.mjs src/llm/providers/anthropic.test.ts src/llm/providers/openai-completions.test.ts(28 passed)node ./node_modules/.bin/oxfmt --check src/llm/providers/anthropic.ts src/llm/providers/openai-completions.ts src/llm/providers/anthropic.test.ts src/llm/providers/openai-completions.test.tsnode scripts/run-oxlint.mjs src/llm/providers/anthropic.ts src/llm/providers/openai-completions.ts src/llm/providers/anthropic.test.ts src/llm/providers/openai-completions.test.tsgit diff --checkpnpm tsgo:prod && pnpm check:test-types.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main(clean after fixing the OpenRouter Anthropic cache-control edge it identified)Notes
The OpenAI-compatible
prompt_cache_keyregression mentioned in #89386 was already repaired on current main by #88976. This PR fixes the remaining cache-boundary split/strip behavior in the refactored provider path.