Skip to content

Commit fe5fb97

Browse files
Handle function call messages with empty content (#203)
* Handle function call messages with empty content * Resolve test failure * Create heavy-yaks-mate.md --------- Co-authored-by: Dominik Kundel <[email protected]>
1 parent a2f78fe commit fe5fb97

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/heavy-yaks-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@openai/agents-openai": patch
3+
---
4+
5+
Handle function call messages with empty content in Chat Completions

packages/agents-openai/src/openaiChatCompletionsModel.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,13 @@ export class OpenAIChatCompletionsModel implements Model {
6767
const output: protocol.OutputModelItem[] = [];
6868
if (response.choices && response.choices[0]) {
6969
const message = response.choices[0].message;
70-
if (message.content !== undefined && message.content !== null) {
70+
71+
if (
72+
message.content !== undefined &&
73+
message.content !== null &&
74+
// Azure OpenAI returns empty string instead of null for tool calls, causing parser rejection
75+
!(message.tool_calls && message.content === '')
76+
) {
7177
const { content, ...rest } = message;
7278
output.push({
7379
id: response.id,

0 commit comments

Comments
 (0)