Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Error if function_tool has a Mapping input #345

Copy link
Copy link
Closed
@TimoVink

Description

@TimoVink
Issue body actions

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

No one assigned

    Labels

    bugSomething isn't workingSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.