MEDIUM SEVERITYCONFIRMED

_parse_function_tool_json_input returns non-dict for valid JSON scalars

Package
openai-agents
Version
0.13.2
Verified
2026-03-28

Description

The return type annotation of `_parse_function_tool_json_input` is `dict[str, Any]`, but `json.loads()` can return `int`, `float`, `bool`, `str`, `list`, or `None` for valid JSON. No isinstance check is performed. For tools with no `failure_error_function`, the resulting `TypeError` from `schema.params_pydantic_model(**non_dict)` propagates as an uncaught exception and crashes the agent run.

Reproduction

from agents.tool import _parse_function_tool_json_input
_parse_function_tool_json_input(tool_name='t', input_json='1')
# returns: 1  (int, not dict)
_parse_function_tool_json_input(tool_name='t', input_json='true')
# returns: True  (bool, not dict)
← All bugsScan your code →