Skip to content

Conversation

@hinnefe2
Copy link
Contributor

@hinnefe2 hinnefe2 commented Dec 11, 2025

Closes #3654 by adding a warning when an OpenAI-powered agent has a tool with a dict-typed argument.


def _map_tool_definition(self, f: ToolDefinition) -> responses.FunctionToolParam:
if _has_dict_typed_params(f.parameters_json_schema):
warnings.warn(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move the warning into the helper method so that we don't repeat the text

tools.append({'type': 'image_generation'})
return tools

def _map_tool_definition(self, f: ToolDefinition) -> responses.FunctionToolParam:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll also need to do the check in _map_json_schema

'properties': {
'dict_list': {'type': 'array', 'items': {'type': 'object', 'additionalProperties': {'type': 'integer'}}}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to test this with a tool function that actually has a dict argument, or a BaseModel argument that itself has a dict field, instead of testing the schemas directly.

So maybe can we build an agent with a tool like that, then run it, and test that a warning was emitted?

Comment on lines +918 to +921
f"Tool '{f.name}' has dict-typed parameters that OpenAI's API will silently ignore. "
f'Use a Pydantic BaseModel with explicit fields instead of dict types, '
f'or switch to a different provider which supports dict types. '
f'See: https://github.com/pydantic/pydantic-ai/issues/3654',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
f"Tool '{f.name}' has dict-typed parameters that OpenAI's API will silently ignore. "
f'Use a Pydantic BaseModel with explicit fields instead of dict types, '
f'or switch to a different provider which supports dict types. '
f'See: https://github.com/pydantic/pydantic-ai/issues/3654',
f"Tool {f.name!r} has `dict`-typed parameters that OpenAI's API will silently ignore. "
f'Use a Pydantic `BaseModel`, `dataclass`, or `TypedDict` with explicit fields instead, '
f'or switch to a different provider which supports `dict` types. '
f'See: https://github.com/pydantic/pydantic-ai/issues/3654',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tool arguments of type dict are invisible to OpenAI-powered agents

2 participants