refactor: apply MCP argument coercion only as a fallback after validation failure - #9823
Merged
Conversation
…tion failure Instead of rewriting tool-call arguments on every request before validation, let the SDK validate the original arguments first; only when validation fails with a JSON-RPC invalid-params error, coerce the stringified fields and retry the call once. Calls that validate as-is are never rewritten. Claude-Session: https://claude.ai/code/session_01QQXgoSbvvNyD9877qZ5Wou
Member
|
If we are doing it only on failures then it may be okay to get rid of the instance config/feature flag as well IMO. |
With coercion applied only as a fallback after validation failure, it can no longer alter a valid request, so the opt-out is unnecessary. Claude-Session: https://claude.ai/code/session_01QQXgoSbvvNyD9877qZ5Wou
Gives operators a signal for how often the client-side serialization bug occurs, and hence when the workaround can be retired. Claude-Session: https://claude.ai/code/session_01QQXgoSbvvNyD9877qZ5Wou
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.
Follow-up to #9821, addressing this review suggestion:
tools/call.coerceMCPToolArgsnow reports whether it changed anything, so unchanged arguments skip the retry and return the original validation error.rill.ai.mcp_tolerant_argsconfig option introduced in fix: tolerantly decode stringified JSON object arguments in MCP tool calls #9821 is removed again (including its docs entry and test).Checklist:
https://claude.ai/code/session_01QQXgoSbvvNyD9877qZ5Wou