High severity intermediate · Fix: 5-10 min

TypeError

pydantic_ai.tool.PydanticAIToolFunctionSignatureError

What this error means
Pydantic AI tools require function signatures to exactly match the expected Pydantic model schema; mismatches cause this TypeError.

Stack trace

traceback
Traceback (most recent call last):
  File "app.py", line 42, in <module>
    result = tool.run(input_data)
  File "pydantic_ai/tool.py", line 128, in run
    raise PydanticAIToolFunctionSignatureError(f"Function signature mismatch: {err}")
pydantic_ai.tool.PydanticAIToolFunctionSignatureError: Function signature mismatch: missing required positional argument 'name'
QUICK FIX
Adjust your function signature to exactly match the Pydantic model fields used by the tool.

Why it happens

Pydantic AI tools introspect the function signature to validate inputs against the Pydantic model schema. If the function parameters do not exactly match the model fields (missing, extra, or misnamed parameters), the tool raises this error to prevent runtime failures.

Detection

Catch PydanticAIToolFunctionSignatureError during tool initialization or execution and log the function signature and expected model fields to identify mismatches early.

Causes & fixes

1

Function parameters do not match the Pydantic model fields exactly (missing or extra parameters).

✓ Fix

Ensure the function signature parameters exactly match the Pydantic model field names and types, including required and optional fields.

2

Parameter names in the function are misspelled or use different casing than the Pydantic model fields.

✓ Fix

Rename function parameters to match the Pydantic model field names exactly, respecting case sensitivity.

3

Using default values in the function signature that conflict with Pydantic model defaults or required fields.

✓ Fix

Align default values in the function signature with those defined in the Pydantic model or remove conflicting defaults.

Code: broken vs fixed

Broken - triggers the error
python
from pydantic_ai import PydanticAITool

class UserModel(BaseModel):
    name: str
    age: int

def process_user(age: int):  # Missing 'name' parameter
    return f"User age is {age}"

tool = PydanticAITool(model=UserModel, func=process_user)
result = tool.run({'name': 'Alice', 'age': 30})  # Raises PydanticAIToolFunctionSignatureError
Fixed - works correctly
python
from pydantic import BaseModel
from pydantic_ai import PydanticAITool

class UserModel(BaseModel):
    name: str
    age: int

def process_user(name: str, age: int):  # Fixed: parameters match model fields
    return f"User {name} is {age} years old"

tool = PydanticAITool(model=UserModel, func=process_user)
result = tool.run({'name': 'Alice', 'age': 30})
print(result)  # Works correctly
Fixed the function signature to exactly match the Pydantic model fields, resolving the signature mismatch error.

Workaround

Wrap the tool.run call in try/except PydanticAIToolFunctionSignatureError, then manually validate and map input dict keys to function parameters before retrying.

Prevention

Always define Pydantic models and corresponding tool functions with matching parameter names and types, and use static type checking or linters to catch mismatches before runtime.

Python 3.9+ · pydantic-ai >=0.1.0 · tested on 0.2.x
Verified 2026-04
Verify ↗

Community Notes

No notes yetBe the first to share a version-specific fix or tip.