mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Codex CLI injects prompt_cache_key natively for its own prompt caching. injectPromptCacheKey() only guards against the router injecting a NEW key for nvidia/codex/xai — it never strips a key that arrived already present in the inbound body. NVIDIA NIM's OpenAI-compatible wrapper rejects the field with a 400, and NIM has no documented support for prompt caching (providerSupportsCaching already treats nvidia as non-cache-capable). Adds a provider-wide STRIP_RULES entry in paramSupport.ts (match-all, since prompt_cache_key rejection isn't model-specific) so stripUnsupportedParams() drops it for every nvidia target before the request reaches DefaultExecutor.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { test } from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { stripUnsupportedParams } from "../../open-sse/translator/paramSupport.ts";
|
|
|
|
test("#7617: stripUnsupportedParams strips prompt_cache_key for nvidia when present", () => {
|
|
const body: Record<string, unknown> = {
|
|
model: "some-nvidia-model",
|
|
prompt_cache_key: "codex-cli-session-abc123",
|
|
max_tokens: 512,
|
|
};
|
|
stripUnsupportedParams("nvidia", "some-nvidia-model", body);
|
|
assert.equal(
|
|
body.prompt_cache_key,
|
|
undefined,
|
|
"prompt_cache_key must be stripped for nvidia"
|
|
);
|
|
assert.equal(body.max_tokens, 512, "unrelated params must be preserved");
|
|
});
|
|
|
|
test("#7617: stripUnsupportedParams preserves prompt_cache_key for non-nvidia providers (e.g. openai)", () => {
|
|
const body: Record<string, unknown> = {
|
|
model: "gpt-5.4",
|
|
prompt_cache_key: "some-cache-key",
|
|
};
|
|
stripUnsupportedParams("openai", "gpt-5.4", body);
|
|
assert.equal(
|
|
body.prompt_cache_key,
|
|
"some-cache-key",
|
|
"prompt_cache_key must be preserved for non-nvidia providers"
|
|
);
|
|
});
|
|
|
|
test("#7617: stripUnsupportedParams is a no-op for nvidia when prompt_cache_key is absent", () => {
|
|
const body: Record<string, unknown> = {
|
|
model: "some-nvidia-model",
|
|
max_tokens: 256,
|
|
};
|
|
stripUnsupportedParams("nvidia", "some-nvidia-model", body);
|
|
assert.equal("prompt_cache_key" in body, false);
|
|
assert.equal(body.max_tokens, 256);
|
|
});
|