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
TypeError crash when function parameter is named 'model_config' #3547
Calling function_schema() (or using @function_tool) on a Python function that has a parameter named model_config (or another Pydantic-reserved name like model_fields, model_computed_fields) causes an unhandled TypeError deep inside Pydantic internals.
fromagents.function_schemaimportfunction_schemadefmy_tool(model_config: str) ->str:
returnmodel_configschema=function_schema(my_tool)
# TypeError: 'FieldInfo' object is not iterable
Full traceback:
File "src/agents/function_schema.py", line 407, in function_schema
dynamic_model = create_model(f"{func_name}_args", __base__=BaseModel, **fields)
File "pydantic/main.py", line 1828, in create_model
File "pydantic/_internal/_model_construction.py", line 131, in __new__
config_wrapper = ConfigWrapper.for_model(bases, namespace, raw_annotations, kwargs)
File "pydantic/_internal/_config.py", line 143, in for_model
config_new.update(config_from_namespace)
TypeError: 'FieldInfo' object is not iterable
Root cause
Pydantic's create_model() treats keyword arguments named model_config as a model-level configuration key, not a field. When function_schema.py passes a FieldInfo for that name, Pydantic's ConfigWrapper.for_model() calls .update() on it expecting a dict-like object, causing the crash. No guard exists to detect reserved names before handing them to create_model().
changed the title [-]BUG: TypeError crash when function parameter is named 'model_config'[/-][+]TypeError crash when function parameter is named 'model_config'[/+]on Jun 4, 2026
Activity
norika1207-lab commentedon Jun 2, 2026
[-]BUG: TypeError crash when function parameter is named 'model_config'[/-][+]TypeError crash when function parameter is named 'model_config'[/+]