Closed
Description
Describe the bug
If an agent is provided with a function_tool
that has a Mapping
or dict
as its input, an HTTP 400 invalid_function_parameters
error is returned when the agent runs.
Example
@function_tool
def foo(x: Mapping[str,str]) -> str:
return 'bar'
foo_agent = Agent(name='Foo Agent', tools=[foo])
await Runner.run(foo_agent, input='foo')
Error:
Error getting response: Error code: 400
{
'error': {
'message': "Invalid schema for function 'foo': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Extra required key 'x' supplied.",
'type': 'invalid_request_error',
'param': 'tools[0].parameters',
'code': 'invalid_function_parameters'
}
}
(request_id: req_f3213fe15078c00d899a910c5567fed4)
If I check foo.params_json_schema
, I get:
{'properties': {'x': {'additionalProperties': {'type': 'string'},
'title': 'X',
'type': 'object'}},
'required': ['x'],
'title': 'foo_args',
'type': 'object',
'additionalProperties': False}
Which looks valid to me at a glance, but I'm not very familiar with the JSON Schema spec.
Debug information
- Agents SDK:
v0.0.6
- Python:
v3.11.9
- Pydantic:
v2.10.6
Metadata
Metadata
Assignees
Labels
Something isn't workingSomething isn't working