diff --git a/open-sse/mcp-server/__tests__/advancedTools.test.ts b/open-sse/mcp-server/__tests__/advancedTools.test.ts index 0fedef6aef..c2aaf4d846 100644 --- a/open-sse/mcp-server/__tests__/advancedTools.test.ts +++ b/open-sse/mcp-server/__tests__/advancedTools.test.ts @@ -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", () => { diff --git a/open-sse/mcp-server/tools/advancedTools.ts b/open-sse/mcp-server/tools/advancedTools.ts index e9fbdc22b7..fef283d8d2 100644 --- a/open-sse/mcp-server/tools/advancedTools.ts +++ b/open-sse/mcp-server/tools/advancedTools.ts @@ -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, }), }) );