Python: apply input_variables defaults when rendering prompt templates - #14459
Open
Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
Open
Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
Manohar Paturi (ManoharPaturi) wants to merge 2 commits into
Conversation
…riptions build_model_schema() preferred FieldInfo.metadata over FieldInfo.description when deriving field descriptions. In pydantic v2, FieldInfo.metadata is a list of constraint objects (annotated_types.Ge, Gt, ...), so for any field declared with a constraint (e.g. Field(description=..., ge=0)) the real description was replaced by the constraint object. The resulting schema carried a non-string 'description' and json.dumps() of the function-calling tool payload failed with 'TypeError: Object of type Ge is not JSON serializable'. Only treat str and dict-with-'description' entries in metadata as descriptions (these come from Annotated metadata), and fall back to FieldInfo.description otherwise.
The per-variable default was validated and exported as metadata but never consulted at render time, so a missing argument rendered as an empty string instead of the declared default. Seed missing arguments with their defaults before rendering; explicit arguments always win. Signed-off-by: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com>
Manohar Paturi (ManoharPaturi)
requested a review
from a team
as a code owner
September 18, 2026 11:48
Manohar Paturi (ManoharPaturi)
had a problem deploying
to
github-app-auth
September 18, 2026 11:48 — with
GitHub Actions
Failure
Manohar Paturi (ManoharPaturi)
had a problem deploying
to
github-app-auth
September 18, 2026 11:48 — with
GitHub Actions
Failure
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.
Fixes #14458.
KernelPromptTemplate.rendernow seeds any missing argument with the declaredinput_variablesdefault before rendering (case-insensitive name check, explicit arguments always win, falsy defaults untouched so the existing empty-string behavior for unset defaults stays).2 regression tests: default applies when the argument is missing, and an explicit argument overrides the default. The default-applies test fails on main. Full prompt_template suite green (13 passed), ruff clean.