feat(proxy): session-based prompt_cache_key routing for Codex Chat bridge

Codex always sends prompt_cache_key in its Responses requests, but the
Responses -> Chat Completions conversion dropped it, breaking session
cache affinity on upstreams that route by key (e.g. Kimi Coding).

- Re-inject prompt_cache_key after conversion in the forwarder: an
  explicit client key wins, otherwise a client-provided session ID;
  generated per-request UUIDs are never sent upstream.
- Provider-aware gating: "auto" enables only known-compatible upstreams
  (api.openai.com, api.kimi.com/coding) because strict gateways reject
  unknown fields with HTTP 400 (e.g. Fireworks); an advanced
  Auto/Enabled/Disabled override is available on the Codex form in all
  four locales.
- Kimi For Coding preset opts in explicitly.
This commit is contained in:
Jason
2026-07-11 21:42:43 +08:00
parent 0e563b50c5
commit a078b4b207
14 changed files with 295 additions and 4 deletions
+4
View File
@@ -6,6 +6,7 @@ import type {
CodexApiFormat,
CodexCatalogModel,
CodexChatReasoning,
PromptCacheRoutingMode,
} from "../types";
import type { PresetTheme } from "./claudeProviderPresets";
@@ -36,6 +37,8 @@ export interface CodexProviderPreset {
modelCatalog?: CodexCatalogModel[];
// Codex Responses -> Chat Completions reasoning capability defaults
codexChatReasoning?: CodexChatReasoning;
// Session-based prompt-cache routing override for Chat Completions upstreams
promptCacheRouting?: PromptCacheRoutingMode;
}
/**
@@ -604,6 +607,7 @@ requires_openai_auth = true`,
),
endpointCandidates: ["https://api.kimi.com/coding/v1"],
apiFormat: "openai_chat",
promptCacheRouting: "enabled",
modelCatalog: modelCatalog([
{
model: "kimi-for-coding",