fix: propagate parameter descriptions in create_tool_call#472
Merged
jjovalle99 merged 1 commit intomainfrom Apr 4, 2026
Merged
fix: propagate parameter descriptions in create_tool_call#472jjovalle99 merged 1 commit intomainfrom
jjovalle99 merged 1 commit intomainfrom
Conversation
_get_function_parameters mutates field_info.description after FieldInfo construction. Pydantic v2 ignores this because _attributes_set is not updated. All docstring-derived parameter descriptions are silently dropped from the generated tool schema. For fresh FieldInfos, pass description to Field() at construction. For existing FieldInfos, override via Annotated stacking (public API).
aac228
approved these changes
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_get_function_parametersmutatesfield_info.descriptionafter FieldInfoconstruction (line 137). Pydantic v2 ignores this mutation in
model_json_schema()because it only reads attributes passed atField()construction time. Pydantic documents this as "only accidentally working"
since
_attributes_setis not updated. All docstring-derived parameterdescriptions are silently dropped from the generated tool schema.
description=directlyto
Field()at construction.Annotated[T, Field(...)]or= Field(...)defaults), override description via Annotated stacking. Pydantic merges
stacked metadata left-to-right,
so the description Field appended last takes precedence while preserving
existing constraints. This is the same pattern Pydantic uses in
rebuild_annotation().No private APIs.
Fixes #471
Test plan
src/mistralai/extra/tests/test_tools.pyshared FieldInfo instances, required vs optional params, no-docstring edge cases