node: do not retry a tool call the provider answered with an error #856
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.48) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 385 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.356
Shallow Review Depth
shallow_review_depth
0.344
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #856"
general
weight: 0.35
aojea
What
CallMCPToolstops retrying when the provider node's task check refuses the call. The rule comes from d2046162:The loop already recognizes
ErrAuthRejectedandErrProviderNotGranted(#722). A tool outside the caller's task is refused later, inside an allowed MCP stream:authorizeMCPRequest(internal/node/mcp_service.go) answers thetools/callitself with a JSON-RPC error, and the MCP backend never sees it. The loop treated that answer as a failure to connect and retried it. Onmainit returns after 3 attempts and about 7 seconds:failed after 3 retries: failed to call tool mcp://code-reviewer/delete_repo: calling "tools/call": task authorization denied tool "delete_repo": tar_block[1] ("review-only") denied request to mcp://code-reviewer
Each retry opens a new stream, so the provider also logs three
TAR deniedwarnings for one call.Fix
authorizeMCPRequestanswers a task denial withcodeTaskDenied(-31403) instead ofCodeInvalidRequest(-32600). This applies to all three denials in that function (initialize/ping/tools/list,tools/call, and other methods), so the same denial has one code. -31403 is AgentMesh's own code, outside the -32768 to -32000 range JSON-RPC reserves; the go-sdk already uses -32001 to -32005, -32002, -32020 to -32022, -32042 and -31001. Nothing in the repo reads the old code. The message text is unchanged, so the examples that match on it keep working.CallMCPToolstops retrying on that code only. Every other error is retried as before, including any JSON-RPC error from the MCP backend (for exampleunknown tool). The loop does not sort backend errors.Tests
TestCallMCPTool_TaskDeniedToolIsNotRetriedis new. It calls a tool outside the caller's task, checks that the answer carriescodeTaskDeniedand comes back once, and then checks that the same task token still reaches the tool it allows. With the caller-side check removed:--- FAIL: TestCallMCPTool_TaskDeniedToolIsNotRetried (7.10s)
mcp_handlers_test.go:747: CallMCPTool(delete_repo) = failed after 3 retries: ... want one answer with no retry
With the fix, it passes in 0.10s. I also checked by hand that a backend
unknown toolerror is still retried three times, as onmain.go test -race ./internal/node/passes (darwin/arm64). On macOS it needs a shortTMPDIR, because the default temp path is longer than the Unix socket limit for the sidecar tests.go test ./internal/... ./api/...passes.gofmtandgo vetare clean, andgolangci-lintv2.14.0 (the versionhack/lint.shuses) reports 0 issues on./internal/node/....Not changed here
site/content/docs/use-cases/private-diy-stack.mdshows sample output for a denied tool that starts withfailed after 3 retries:. With this change that prefix goes away. I can update the sample here if you want.