Fix mcp_invoke_tool flat-args self-healing#445
Merged
Conversation
The agent intermittently dropped the `arguments` wrapper on mcp_invoke_tool
calls, inlining inner-tool fields at the top level (e.g. server_name,
tool_name, accountId, query as siblings). McpManagementExecutor handled
the nested-wrapper case and the empty-args case but not this third shape —
so the call dispatched with no inner args and the MCP server rejected with
"X is required." Recovery's enricher then surfaced a missing-field error
to the LLM even though the LLM had passed the field one level up.
Add a third branch that promotes every non-reserved top-level key into a
synthetic `arguments` object before dispatch, so the call still works.
Also tighten the wisp auto-corrector: when the step has empty params AND
no enriched recovery context, decline up-front rather than asking the
cheap-tier LLM to invent values. In practice it ignored the NO_CORRECTION
instruction and emitted things like {"query":"*"} or {"query":""} —
schema-clean but semantically empty — which caused downstream archive
steps to fail without any signal that the search itself was bogus.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
argumentswrapper onmcp_invoke_tooland inlined inner-tool fields at the top level (e.g.server_name,tool_name,accountId,queryall as siblings),McpManagementExecutor.InvokeToolAsyncdispatched the call with no inner args. The MCP server rejected with "X is required", and recovery's enricher surfaced a missing-field error to the LLM — even though the LLM had supplied the field, just one level up. Spotted in the live cluster log when the agent looped onsearch_emailsandmove_email.McpManagementExecutor): Added the missing third branch. When there's no nestedarguments/params/argswrapper but there ARE non-reserved top-level keys, promote them into a syntheticargumentsobject before dispatch. Reserved wrapper keys are excluded so they don't leak into the inner call.WispExecutor.TryAutoCorrectMcpParamsAsync): When the step has empty params AND no enriched recovery context, decline auto-correction up-front instead of asking the cheap-tier LLM to invent values. In practice it ignoredNO_CORRECTIONand emitted things like{"query":"*"}or{"query":""}— schema-clean but semantically empty — causing downstream archive steps to fail without any signal the search itself was bogus.Test plan
InvokeTool_FlatTopLevelFields_PromotedIntoArguments,InvokeTool_NestedArgsTakePrecedenceOverFlatFields,ValidationFailure_EmptyParamsAndNoEnrichedContext_LlmNotCalled,ValidationFailure_EmptyParamsButEnrichedContextPresent_LlmStillCalled,IsEffectivelyEmptyParams_RecognizesEmptyShapes)RockBot.Tools.Testssuite green (193/193)RockBot.Wisp.Testssuite green (132/132)rockylhotka/rockbot-agent:0.12.23and helm-upgraded; pod healthy, agent boots cleanmcp_invoke_toolround-trips successfully (proper-shape happy path)promoted N flat top-level field(s)log line — depends on the LLM emitting the broken shape again, which is intermittent🤖 Generated with Claude Code