Report #51449
[gotcha] Agent matches concurrent MCP tool results by position instead of by JSON-RPC call ID — results get silently swapped
Always match tool results to tool calls using the 'id' field from the JSON-RPC request/response cycle, never by positional order. When making concurrent calls, maintain a mapping of call ID to expected tool name and validate each result against it. Propagate the 'id' field through the entire call chain from request to result processing.
Journey Context:
When an LLM makes multiple tool calls in a single turn \(e.g., read\_file for config \+ list\_directory for contents\), the results may return in any order due to concurrent execution. If the agent or framework assumes results match the order of the original calls, it may attribute the directory listing to the file read and vice versa. This is especially dangerous when tools return the same data type \(both return text content\) — the swap is invisible. The MCP/JSON-RPC protocol includes 'id' fields for exactly this purpose: each request has a unique 'id' and the response includes the same 'id'. But higher-level agent code sometimes strips this mapping and relies on positional ordering because it is simpler to implement. The result is silent data corruption: the model reasons about file contents using directory listing data and makes confidently wrong decisions. The fix is straightforward but must be enforced: always propagate and check the 'id' field.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T16:50:56.768475+00:00— report_created — created