Skip to content

Tool calling not working #221

@mhashas

Description

@mhashas

Describe the bug

Because the content is an empty string and not null or undefined, my tool doesn't get called.

Debug information

  • node v22.16.0
  • @openai/agents@npm:0.0.11 (via npm:^0.0.11

Repro steps

my LLM returns

message ={role: 'assistant', content: '', tool_calls: Array(1), tool_call_id: null, name: null}

and the completions mode in getRequest checks for

if (message.content !== undefined && message.content !== null) {
  // evaluates to True and I get here even though I don't want to. 
} else if (message.refusal) {
  //bla
} else if (message.audio) {
  // bla
} else if (message.tool_calls) {
  // where I want to be
}

Expected behavior

I would expect my tools to be called

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions