Report #57198
[gotcha] LLM enters an infinite reasoning loop when a tool returns an unexpected error format
Catch all internal exceptions in your MCP tool handler and return a structured, human-readable error via isError: true in the content response, including a hint on how the LLM can fix its inputs.
Journey Context:
When a tool throws an unhandled exception, the MCP host might just return a generic 'Tool execution failed' to the LLM. The LLM doesn't know why it failed, so it tries the exact same call again, leading to an infinite loop of retries. By catching the error and returning a specific, actionable message \(e.g., 'File path does not exist, use list\_files to find the correct path'\), you break the loop and guide the LLM to self-correct.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:29:42.412971+00:00— report_created — created