Skip to content

Commit 191b82a

Browse files
fix: the aisdk extension should grab output when toolCalls is a blank array (#308)
When the output of a provider includes an empty tool calls array, we'd mistakenly skip over the text result. This patch checks for that condition.
1 parent d639151 commit 191b82a

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

.changeset/big-horses-itch.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@openai/agents-extensions': patch
3+
---
4+
5+
fix: the aisdk extension should grab output when toolCalls is a blank array
6+
7+
When the output of a provider includes an empty tool calls array, we'd mistakenly skip over the text result. This patch checks for that condition.

packages/agents-extensions/src/aiSdk.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,10 @@ export class AiSdkModel implements Model {
463463
// Putting a text message here will let the agent loop to complete,
464464
// so adding this item only when the tool calls are empty.
465465
// Note that the same support is not available for streaming mode.
466-
if (!result.toolCalls && result.text) {
466+
if (
467+
(!result.toolCalls || result.toolCalls.length === 0) &&
468+
result.text
469+
) {
467470
output.push({
468471
type: 'message',
469472
content: [{ type: 'output_text', text: result.text }],

0 commit comments

Comments
 (0)