fix(mcp): remove non-standard x-provider field from omniroute_test_combo body (#9274)

Validated in local merge-train (devbox-vm-06-dev002) @ combined-tip (FAST gates green: static + changed tests + vitest — only pre-existing audit.test.ts flake). Evidence: /home/diegosouzapw/dev/proxys/OmniRoute/.claude/worktrees/merge-train-20260805-213228-suite.log
This commit is contained in:
SAMUEL AUGUSTO GUIMARAES LOPES
2026-08-05 21:45:41 -03:00
committed by GitHub
parent a4d79c81aa
commit d61d7f7f95
2 changed files with 32 additions and 1 deletions

View File

@@ -9,9 +9,15 @@ import { describe, it, expect, vi, beforeEach } from "vitest";
const mockFetch = vi.fn();
vi.stubGlobal("fetch", mockFetch);
const { handleTestCombo } = await import("../tools/advancedTools.ts");
describe("MCP Advanced Tools", () => {
beforeEach(() => {
mockFetch.mockReset();
// Re-assert the stub: importing advancedTools.ts triggers OmniRoute's own
// startup side effects (DB init, global fetch proxy patch) that overwrite
// globalThis.fetch after the top-level vi.stubGlobal() above ran.
vi.stubGlobal("fetch", mockFetch);
});
describe("simulate_route", () => {
@@ -82,6 +88,32 @@ describe("MCP Advanced Tools", () => {
expect(combo).toBeDefined();
expect(combo.models).toHaveLength(2);
});
it("does not send a non-standard 'x-provider' body field upstream (regression, strict providers like Groq reject it with HTTP 400)", async () => {
mockFetch
.mockResolvedValueOnce({
ok: true,
json: async () => [
{
id: "groq-combo",
models: [{ provider: "groq", model: "groq/llama-3.1-8b-instant" }],
},
],
})
.mockResolvedValueOnce({
ok: true,
json: async () => ({ model: "llama-3.1-8b-instant", cost: 0, usage: {} }),
});
await handleTestCombo({ comboId: "groq-combo", testPrompt: "hi" });
const chatCompletionsCall = mockFetch.mock.calls.find(([url]) =>
String(url).includes("/v1/chat/completions")
);
expect(chatCompletionsCall).toBeDefined();
const sentBody = JSON.parse(chatCompletionsCall![1].body);
expect(sentBody).not.toHaveProperty("x-provider");
});
});
describe("get_provider_metrics", () => {

View File

@@ -548,7 +548,6 @@ export async function handleTestCombo(args: { comboId: string; testPrompt: strin
messages: [{ role: "user", content: prompt }],
max_tokens: 50,
stream: false,
"x-provider": model.provider,
}),
})
);