Repository navigation
fix(sdk): accept underscore-prefixed MCP argument names - #6381
Merged
VascoSch92 merged 3 commits intoNov 5, 2026
Merged
Conversation
Closed
75 of 86 tasks
VascoSch92
enabled auto-merge (squash)
November 4, 2026 09:50
auto-merge was automatically disabled
November 4, 2026 09:54
Head branch was modified
VascoSch92
enabled auto-merge (squash)
November 4, 2026 09:57
auto-merge was automatically disabled
November 4, 2026 09:58
Head branch was modified
VascoSch92
enabled auto-merge (squash)
November 5, 2026 08:50
auto-merge was automatically disabled
November 5, 2026 08:53
Head branch was modified
VascoSch92
enabled auto-merge (squash)
November 5, 2026 15:32
Member
|
sorry I had to close it and re-open it. GH was buggy |
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.
HUMAN:
Fixed the underscore-prefixed MCP argument crash from #6348. I reviewed the diff and the test; MCP argument names are the server's choice, not ours.
AGENT:
Why
Schema.from_mcp_schemapasses MCP argument names straight topydantic.create_model, which refuses names with a leading underscore (NameError: Fields must not use names with leading underscores). A tool that declares an argument such as_cursor— a normal JSON key for its producer — crashed action construction inAgent._get_action_event, which catchesValidationErrorbut notNameError.Summary
kind): keep the external name as the Pydantic alias and use a safe internal field name, somodel_dump(by_alias=True)still emits the original key.test_mcp_action_from_arguments_accepts_underscore_prefixed_argumentfrom theworktree-test-edge-casesbranch (commit f2fcf6e) without itsxfail(strict=True)marker, per the [Bug]: Edge-case tests expose ~70 bugs across the SDK, agent server, tools and workspaces #6348 menu's acceptance criteria.Issue Number
Part of #6348 (menu sub-item: "Schema.from_mcp_schema passes MCP argument names straight to pydantic.create_model, so '_'-prefixed names ...")
How to Test
Before this change the tool raises
NameError; after,action_from_arguments({"_cursor": "abc"}).data == {"_cursor": "abc"}.tests/sdk/mcp/plustests/sdk/tool/is 433 passed, with one pre-existing environment failure (test_create_mcp_tools_connection_to_nonexistent_server, which fails the same way without this change).ruff check/formaton the touched files are clean.Type
Notes
Only the leading-underscore case is aliased; ordinary argument names keep their current field names.