diff --git a/open-sse/config/providerFieldStrips.ts b/open-sse/config/providerFieldStrips.ts index 74282febdc..7568cd80bd 100644 --- a/open-sse/config/providerFieldStrips.ts +++ b/open-sse/config/providerFieldStrips.ts @@ -56,12 +56,21 @@ export function stripGroqUnsupportedFields>(bo delete next.top_logprobs; if (Array.isArray(next.messages)) { next.messages = next.messages.map((m) => { - if (m && typeof m === "object" && "name" in m) { - const { name: _name, ...rest } = m as Record; + if (m && typeof m === "object") { + const { + name: _name, + model: _model, + messageId: _msgId, + sender: _sender, + ...rest + } = m as Record; + return rest; } + return m; }); } return next as T; } + diff --git a/tests/unit/provider-field-strips.test.ts b/tests/unit/provider-field-strips.test.ts index 5323683617..b136c6601b 100644 --- a/tests/unit/provider-field-strips.test.ts +++ b/tests/unit/provider-field-strips.test.ts @@ -53,3 +53,27 @@ test("stripGroqUnsupportedFields is immutable (does not mutate input)", () => { assert.equal(input.messages[0].name, "bob"); assert.equal(input.logprobs, true); }); + +test("stripGroqUnsupportedFields drops unsupported messages[].model and other metadata while keeping role and content", () => { + const out = stripGroqUnsupportedFields({ + messages: [ + { role: "user", content: "hello" }, + { + role: "assistant", + content: "hello!", + model: "groq/openai/gpt-oss-20b", + messageId: "msg_123", + sender: "assistant", + }, + ], + }); + assert.equal(out.messages.length, 2); + assert.equal(out.messages[0].role, "user"); + assert.equal(out.messages[0].content, "hello"); + assert.equal(out.messages[1].role, "assistant"); + assert.equal(out.messages[1].content, "hello!"); + assert.equal("model" in out.messages[1], false); + assert.equal("messageId" in out.messages[1], false); + assert.equal("sender" in out.messages[1], false); +}); +