agents: forward prompt_cache_key on openai-completions when compat.supportsPromptCacheKey is set#69411
agents: forward prompt_cache_key on openai-completions when compat.supportsPromptCacheKey is set#69411sk7n4k3d wants to merge 1 commit into
Conversation
…pportsPromptCacheKey is set
Greptile SummaryThis PR wires Confidence Score: 5/5Safe to merge — the change is well-scoped, default-off, and thoroughly tested. The implementation mirrors the existing Responses API pattern precisely, the three-condition gate preserves backward compatibility, all five new test cases correctly exercise the branches, and no existing behaviour is altered when supportsPromptCacheKey is absent or false. No files require special attention. Reviews (1): Last reviewed commit: "agents: forward prompt_cache_key on open..." | Re-trigger Greptile |
|
Closing this as implemented after Codex review. Current What I checked:
So I’m closing this as already implemented rather than keeping a duplicate issue open. Codex Review notes: reviewed against 2cd2732ab669; fix evidence: commit 2cd2732ab669. |
Summary
Fixes #69272.
buildOpenAICompletionsParamsnever emittedprompt_cache_keyon theCompletions path, so operators running OpenAI-compatible proxies (vLLM,
SGLang, Chutes, etc.) could not opt into stable prompt caching per session
the way
buildOpenAIResponsesParamsalready does for the Responses API.This change forwards
options.sessionIdasprompt_cache_keyon theCompletions path under all three of the following conditions:
model.compat.supportsPromptCacheKey === true(explicit opt-in, defaultsto the existing behavior — nothing emitted — when unset or false).
resolveCacheRetention(options?.cacheRetention) !== "none"(mirrors theResponses API gate at
src/agents/openai-transport-stream.ts:794).options?.sessionIdis present.Conservative default preserves #49877 / #48155 (Volcano Engine DeepSeek
rejects unknown fields) and the scope maintainers set in #67427.
Why not covered by #67427
#67427 added
compat.supportsPromptCacheKeyto gate the Responses APIstrip. That is the right mechanism, but it only affected Responses API
payloads. The Completions builder had no knob at all. This PR wires the
same flag through the second code path.
Changes
src/agents/openai-transport-stream.ts— added the conditional emit inbuildOpenAICompletionsParamswith an explanatory comment matching theResponses API emission.
src/agents/openai-transport-stream.test.ts— 5 new tests covering:compat.supportsPromptCacheKey, sessionId present) → not emittedcompat.supportsPromptCacheKey=true+ sessionId → emittedcompat.supportsPromptCacheKey=true+cacheRetention: "none"→ suppressedcompat.supportsPromptCacheKey=true+ no sessionId → suppressedcompat.supportsPromptCacheKey=false→ suppressedScope
Nothing else touched:
cacheRetention, or GeminicachedContents.Test plan
pnpm test src/agents/openai-transport-stream.test.ts— 70/70 passedpnpm tsgo:core— cleanpnpm tsgo:core:test— cleanpnpm lint— clean (via committercheck:changed)pnpm format— cleanAI-assisted: yes (Claude, under sk7n4k3d supervision).