mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-02 21:32:10 +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.
This commit is contained in:
committed by
GitHub
parent
5d755c3338
commit
9e535e5ca1
1
changelog.d/fixes/7617-nvidia-strip-cache-key.md
Normal file
1
changelog.d/fixes/7617-nvidia-strip-cache-key.md
Normal file
@@ -0,0 +1 @@
|
||||
- fix(routing): strip `prompt_cache_key` for NVIDIA NIM — Codex CLI injects it, NIM's OpenAI-compatible wrapper 400s on it (#7617)
|
||||
@@ -50,6 +50,11 @@ const STRIP_RULES: StripRule[] = [
|
||||
// (format:"openai") does not accept the Claude-style `thinking` body field
|
||||
// and returns 400 "Unsupported parameter(s): thinking". Upstream #2268.
|
||||
{ provider: "nvidia", match: /minimax-m2\.7/i, drop: ["thinking"] },
|
||||
// NVIDIA NIM: OpenAI-compatible wrapper 400s on `prompt_cache_key` (Codex CLI
|
||||
// injects it natively for its own prompt caching). NIM has no documented
|
||||
// support for this field (providerSupportsCaching already treats nvidia as
|
||||
// non-cache-capable) — safe to drop provider-wide, not model-specific. #7617.
|
||||
{ provider: "nvidia", match: /.*/, drop: ["prompt_cache_key"] },
|
||||
// VolcEngine Ark caps the Kimi coding-plan endpoint at max_tokens <= 32768
|
||||
// server-side ("integer above maximum value, expected a value <= 32768"),
|
||||
// independent of the model's own catalog ceiling. Confirmed against two
|
||||
|
||||
41
tests/unit/nvidia-strip-prompt-cache-key.test.ts
Normal file
41
tests/unit/nvidia-strip-prompt-cache-key.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user