fix: preserve null types in tool parameter schemas for LLM#4579
Conversation
Tool parameter schemas were stripping null from optional fields via
generate_model_description, forcing the LLM to provide non-null values
for fields.
Adds strip_null_types parameter to generate_model_description and passes False when generating tool
schemas, so optional fields keep anyOf: [{type: T}, {type: null}]
greysonlalonde
left a comment
There was a problem hiding this comment.
Just ensure you test on native tool calling for anthropic and openai, otherwise these may result in validation errors
@greysonlalonde I've already tested it.. everything works well. I can share examples if you'd like |
Nope, good with me. I think accept @gabemilani 's nit, then gtg 👍 |
Co-authored-by: Gabe Milani <gabriel@crewai.com>
done! |
Tool parameter schemas were stripping null from optional fields via generate_model_description, forcing the LLM to provide non-null values for fields.
Adds strip_null_types parameter to generate_model_description and passes False when generating tool schemas, so optional fields keep anyOf: [{type: T}, {type: null}]