Skip to content

Commit 515c891

Browse files
authored
fix(provider/openai-compatible): duplicated tool-input-start in certain cases (vercel#8108)
1 parent 12c7493 commit 515c891

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

.changeset/pretty-candles-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@ai-sdk/openai-compatible': patch
3+
---
4+
5+
fix duplicated tool-input-start in certain cases

packages/openai-compatible/src/openai-compatible-chat-language-model.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,9 +1523,9 @@ describe('doStream', () => {
15231523
"type": "tool-input-start",
15241524
},
15251525
{
1526+
"delta": "{"",
15261527
"id": "call_O17Uplv4lJvD6DVdIvFFeRMw",
1527-
"toolName": "test-tool",
1528-
"type": "tool-input-start",
1528+
"type": "tool-input-delta",
15291529
},
15301530
{
15311531
"delta": "va",
@@ -1773,9 +1773,9 @@ describe('doStream', () => {
17731773
"type": "tool-input-start",
17741774
},
17751775
{
1776+
"delta": "{"value":"Sparkle Day"}",
17761777
"id": "call_O17Uplv4lJvD6DVdIvFFeRMw",
1777-
"toolName": "test-tool",
1778-
"type": "tool-input-start",
1778+
"type": "tool-input-delta",
17791779
},
17801780
{
17811781
"id": "call_O17Uplv4lJvD6DVdIvFFeRMw",

packages/openai-compatible/src/openai-compatible-chat-language-model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,9 +538,9 @@ export class OpenAICompatibleChatLanguageModel implements LanguageModelV2 {
538538
// send delta if the argument text has already started:
539539
if (toolCall.function.arguments.length > 0) {
540540
controller.enqueue({
541-
type: 'tool-input-start',
541+
type: 'tool-input-delta',
542542
id: toolCall.id,
543-
toolName: toolCall.function.name,
543+
delta: toolCall.function.arguments,
544544
});
545545
}
546546

0 commit comments

Comments
 (0)