fix: alias-normalize CallToolResult structuredContent after validate - #3468
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
This PR has been closed automatically. This repo only keeps pull requests open when they come from a maintainer, or from a contributor a maintainer has assigned to the linked issue, and you aren't currently assigned to #3467. If a maintainer assigns you to #3467, this PR reopens on its own and there's nothing more you need to do here. Assignment is a maintainer call based on capacity; comments that only ask to be assigned don't factor in. What does help is engaging on the issue itself by confirming the repro, explaining why it matters for your use case, or describing the approach you'd take. You're welcome to keep pushing commits here (just avoid force-pushing, since GitHub can't reopen a rewritten branch), but that on its own won't get the PR reviewed or the issue assigned, and realistically most auto-closed PRs stay closed. There's no need to open a new PR either way. CONTRIBUTING.md has the full reasoning, but in short:
Maintainers: reopen, remove |
Fixes #3467
Summary
FuncMetadata.convert_resultvalidatesCallToolResult.structured_contentbut returns the result unchanged. Plain model returns validate thenmodel_dump/dump_pythonwithby_alias=True, so wire keys matchoutputSchema. The CallToolResult path skipped that dump, so Python field names that pass validation (populate_by_name/by_name) could be emitted whileoutputSchemaadvertises aliases.Motivation and Context
Clients validating
structuredContentagainst the publishedoutputSchemareject otherwise-valid tool results when aliases are used. This aligns the CallToolResult short-circuit with the plain-return path (#1073 / #1099). Distinct from #3100 / #3118 (schema generation mode).How Has This Been Tested?
test_call_tool_result_structured_content_alias_normalizedpy -3.12 -m pytest tests/server/mcpserver/test_func_metadata.py— 59 passed{"first":...}instead of{"field_first":...}Breaking Changes
None intended. Wire output for CallToolResult tools that previously leaked Python field names will now use aliases (matching schema / plain returns).
Types of changes
Checklist
help wanted, or I'm a maintainer)Additional context
Smallest fix: after
validate_python(..., by_alias=True, by_name=True)on CallToolResult.structured_content, dump withby_alias=Trueandmodel_copythe normalized dict — same serialization as the plain-return path.AI disclosure
This PR was prepared with AI assistance (Cursor / Grok): issue draft, repro, patch, and PR text. Changes were verified locally on current
main(08a3bc8) with the new regression test and the fulltest_func_metadata.pyfile.