fix: map reasoning-delta to reasoning_content instead of content (#11847)

The Vercel stream converter was incorrectly mapping reasoning-delta
events to delta.content, causing reasoning/thinking content to be
treated as regular assistant content. This fix maps it to
delta.reasoning_content so downstream consumers can properly
distinguish reasoning from regular output.

Fixes #11069

Co-authored-by: MumuTW <clothl47364@gmail.com>
This commit is contained in:
Dallin Romney 2026-03-25 16:39:29 -07:00 • committed by GitHub
parent ff89a88299
commit a936c9d04d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View file

@ -34,7 +34,10 @@ describe("convertVercelStreamPart", () => {
const result = convertVercelStreamPart(part, options);
expect(result).not.toBeNull();
expect(result?.choices[0].delta.content).toBe("Let me think...");
expect((result?.choices[0].delta as any).reasoning_content).toBe(
"Let me think...",
);
expect(result?.choices[0].delta.content).toBeUndefined();
});
test("returns null for tool-call without thoughtSignature", () => {

View file

@ -94,8 +94,13 @@ export function convertVercelStreamPart(
});
case "reasoning-delta":
return chatChunk({
content: part.text,
return chatChunkFromDelta({
delta: {
role: "assistant",
reasoning_content: part.text,
} as ChatCompletionChunk.Choice["delta"] & {
reasoning_content?: string;
},
model,
});