What breaks
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.
from agents.function_schema import function_schema
def my_tool(model_config: str) -> str:
return model_config
schema = 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().
What breaks
Calling
function_schema()(or using@function_tool) on a Python function that has a parameter namedmodel_config(or another Pydantic-reserved name likemodel_fields,model_computed_fields) causes an unhandledTypeErrordeep inside Pydantic internals.Full traceback:
Root cause
Pydantic's
create_model()treats keyword arguments namedmodel_configas a model-level configuration key, not a field. Whenfunction_schema.pypasses aFieldInfofor that name, Pydantic'sConfigWrapper.for_model()calls.update()on it expecting a dict-like object, causing the crash. No guard exists to detect reserved names before handing them tocreate_model().