-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Question
Been digging into how PydanticAI generates JSON schemas for Claude and found something odd.
Anthropic's official @beta_tool decorator (from their Python SDK) generates schemas like this:
{
"properties": {
"location": {
"title": "Location", # ← included
"type": "string"
},
"unit": {
"title": "Unit", # ← included
"type": "string"
}
}
}
Every test case in anthropic-sdk-python/tests/lib/tools/test_functions.py shows the title field being generated and kept.
PydanticAI explicitly strips them out:
class GenerateToolJsonSchema(GenerateJsonSchema):
def _named_required_fields_schema(self, named_required_fields):
# Remove largely-useless property titles
s = super()._named_required_fields_schema(named_required_fields)
for p in s.get('properties', {}):
s['properties'][p].pop('title', None) # ← removes titles
return s
Result:
{
"properties": {
"location": {"type": "string"}, # no title
"unit": {"type": "string"} # no title
}
}
Anthropic's docs show minimal schemas without titles, but @beta_tool generates them via Pydantic's defaults. Other libraries (instructor, langroid) also strip titles for efficiency. Haven't found any reported issues with PydanticAI's approach.
If Anthropic built their decorator to include titles, wouldn't that suggest Claude works better with them? Or did they just not bother optimizing it out?
Has anyone actually tested tool calling quality with/without property titles? Genuinely curious if this matters or if it's just micro-optimization with no real impact.