mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 12:44:18 +08:00
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:
@@ -129,6 +129,14 @@ const expectedChatPresets = new Map<
|
||||
]);
|
||||
|
||||
describe("Codex Chat provider presets", () => {
|
||||
it("enables session-based prompt cache routing for Kimi Coding", () => {
|
||||
const preset = codexProviderPresets.find(
|
||||
(item) => item.name === "Kimi For Coding",
|
||||
);
|
||||
|
||||
expect(preset?.promptCacheRouting).toBe("enabled");
|
||||
});
|
||||
|
||||
it("marks migrated Chat Completions presets for local routing", () => {
|
||||
for (const [name, expected] of expectedChatPresets) {
|
||||
const preset = codexProviderPresets.find((item) => item.name === name);
|
||||
|
||||
Reference in New Issue
Block a user