Skip to content

fix(prompts): honor field aliases when rendering prompts - #5836

Merged
zzstoatzz merged 3 commits into
PrefectHQ:mainfrom
BlueX888:fix/prompt-argument-aliases
Nov 10, 2026
Merged

zzstoatzz merged 3 commits into
PrefectHQ:mainfrom
BlueX888:fix/prompt-argument-aliases

Conversation

@BlueX888

@BlueX888 BlueX888 commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #5835

Prompt arguments with Pydantic aliases are advertised under their input names, but rendering previously filtered them by Python parameter name and discarded the values. Resolve advertised names back to their parameters for JSON-string conversion and preserve those input keys for Pydantic validation. When both alias and a string validation_alias are present, prefer validation_alias, matching the advertised schema; supplied values then override defaults correctly. Injected dependencies remain excluded from caller arguments.

from pydantic import Field
from fastmcp.prompts import Prompt

def total(numbers: list[int] = Field(alias="Numbers", validation_alias="Input")) -> str:
    return f"sum={sum(numbers)}"

prompt = Prompt.from_function(total)
result = await prompt.render({"Input": "[1, 2, 3]"})  # sum=6

Prepared with Codex.

@github-actions

This comment has been minimized.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T09:32:37.118443Z 28e9807 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@marvin-context-protocol marvin-context-protocol Bot added the bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. label Oct 19, 2026
Prompt arguments are advertised from the Pydantic call schema, so an alias
declared through Annotated metadata or a Field(...) default is listed under
the alias. render() checked the required set against the advertised names,
then converted and filtered the arguments by Python parameter name, silently
dropping the alias key before validation: the request failed with
`Name Missing required argument`, and sending the Python name failed the
required check.

Map advertised names back to their Python parameters for string conversion
and keep alias keys in the signature filter; the type adapter validates them
under the alias, as it does for tools.

Co-Authored-By: Claude Code <noreply@anthropic.com>

@fastmcp-triage-reviewer fastmcp-triage-reviewer Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by the FastMCP triage reviewer bot.

One alias case still fails: Field(alias="Name", validation_alias="Input") advertises Input, but the helper chooses Name. Rendering drops supplied values: required arguments error and optional arguments silently use defaults.

Please prefer string validation_alias over alias and add required/defaulted dual-alias tests, including typed JSON-string conversion.

Checks

Both failures reproduced on this revision; the existing 71 prompt-module tests pass.

zzstoatzz added a commit that referenced this pull request Oct 29, 2026
Separate concise, PR-bound contributor feedback from retained triage reports. Keep internal reasoning and command transcripts out of both publication paths, with regression coverage from the #5836 review.

Copy link
Copy Markdown
Contributor Author

Fixed in 10852bd: string validation_alias now takes precedence over alias. Required and defaulted JSON-string cases pass; tests/prompts: 83 passed; applicable prek checks passed.

@fastmcp-triage-reviewer fastmcp-triage-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by the FastMCP triage reviewer bot.

The updated alias precedence fixes the earlier required/defaulted failures. Advertised string aliases now survive filtering and receive typed conversion without allowing callers to override injected dependencies. No additional consequential defect was confirmed in the exercised paths.

Checks

Copied PR tests fail in 8 alias cases on unchanged code; all 73 pass at 10852bd. Two additional probes pass, including real client dispatch, defaults, integer conversion, and dependency protection.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@zzstoatzz
zzstoatzz merged commit a450fd8 into PrefectHQ:main Nov 10, 2026
26 checks passed
zzstoatzz added a commit that referenced this pull request Nov 10, 2026
* Revert "fix: preserve referenced schema definitions (#5588)"

This reverts commit 5f1d152.

* Revert "fix(server): rebuild tool argument errors instead of echoing pydantic's (#6107)"

This reverts commit 8fba5f7.

* Revert "Advertise the MCP Apps extension only when the server serves an app (#5062)"

This reverts commit b89222b.

* Revert "fix(tasks): retain results after tool removal (#5507)"

This reverts commit 711575a.

* Revert "fix(client): Prevent stale ClientGroup refreshes from replacing newer routes (#5543)"

This reverts commit 365d5d2.

* Revert "fix(prompts): honor field aliases when rendering prompts (#5836)"

This reverts commit a450fd8.

* Revert "Stop FastMCP callable caches from retaining dropped tools (#6147)"

This reverts commit 713f247.

* Revert "feat(auth): Add KeystoneTokenVerifier (#6264)"

This reverts commit c33f3de.

* Revert "fix(json-schema): keep x-unsupported-pattern when a format is set (#5731)"

This reverts commit dc9849d.

* Revert "Roll back the tool stamp when a tool registration is rejected (#5798)"

This reverts commit d6566c5.

* Revert "fix(server): validate cursors when pagination is disabled (#6045)"

This reverts commit 4917bee.

* Revert "Keep constraints on scalar schema references (#6041)"

This reverts commit e5176c9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working. Reports of errors, unexpected behavior, or broken functionality. bypass-issue-check

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Aliased prompt arguments are advertised by name but can never be rendered

2 participants