Skip to content

Tool Call with arguments: "" fails due to JSON parsing error #664

@pReya

Description

@pReya

Describe the bug

My problem is very similar to the problem described in #499, however I'm using vercel/ai instead of OpenRouter (though this should be irrelevant here, I think).

Tool calls should not fail when there is an empty string in arguments: "". While this might be a wrong format by the caller, the Agents SDK should still be robust enough to not crash.

The exact error I'm getting is:

error: SyntaxError: Unexpected end of JSON input
      at JSON.parse (<anonymous>)
      at runSingleTool (/Users/user1/backend/node_modules/@openai/agents-core/src/runImplementation.ts:1194:5)
      at Array.map (<anonymous>)
      at executeFunctionToolCalls (/Users/user1/node_modules/@openai/agents-core/src/runImplementation.ts:1335:25)
      at resolveTurnAfterModelResponse (/Users/user1/node_modules/@openai/agents-core/src/runImplementation.ts:711:7)
      at Runner.#runStreamLoop (/Users/user1/node_modules/@openai/agents-core/src/run.ts:1113:65)
      at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

I've logged the Tool call object (toolRun.toolCall in executeFunctionToolCalls()) :

{
  "type": "function_call",
  "callId": "toolu_01XvwabcXWkJrR7iTECAJxwX",
  "name": "list_teams",
  "status": "completed",
  "arguments": ""
}

Debug information

  • Agents SDK version: 0.3.2
  • Runtime environment: Node.js v22.17.1

Repro steps

I'm not sure how to come up with a reproduction, since this relies on an external MCP server in my case.

Expected behavior

The empty string should be handled/parsed gracefully without resulting in a crash.

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