You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
function_schema() raises opaque ValueError for params named model_dump / model_validate / etc. #3549
Calling function_schema() (or using @function_tool) on a function whose parameter is named model_dump, model_dump_json, model_validate, model_validate_json, or model_validate_strings raises an unhandled ValueError deep inside Pydantic rather than a clear SDK error.
File ".../src/agents/function_schema.py", line 407, in function_schema
dynamic_model = create_model(f"{func_name}_args", __base__=BaseModel, **fields)
...
File ".../pydantic/_internal/_fields.py", line 97, in _check_protected_namespaces
raise ValueError(...)
ValueError: Field 'model_validate' conflicts with member <bound method BaseModel.model_validate ...>
of protected namespace 'model_validate'.
Pydantic's create_model() refuses any field whose name matches a built-in BaseModel method in a protected namespace. The error message gives no hint that the issue is the parameter name or how to fix it. These five names are distinct from model_config / model_fields / model_computed_fields (covered by PR #3548, which surfaces a different TypeError).
The fix is to detect these names before calling create_model() and raise a UserError with an actionable message.
changed the title [-]BUG: function_schema() raises opaque ValueError for params named model_dump / model_validate / etc.[/-][+]function_schema() raises opaque ValueError for params named model_dump / model_validate / etc.[/+]on Jun 4, 2026
Activity
norika1207-lab commentedon Jun 2, 2026
[-]BUG: function_schema() raises opaque ValueError for params named model_dump / model_validate / etc.[/-][+]function_schema() raises opaque ValueError for params named model_dump / model_validate / etc.[/+]fix(function_schema): raise UserError for Pydantic protected-namespac…