Auto-retry on [Tool result missing due to internal error]
Problem
During long Claude Code sessions with heavy tool usage, tool calls intermittently return [Tool result missing due to internal error] instead of the actual result. The tool call executes successfully (e.g., a file IS written to disk) but the result is lost in transit back to the model.
This causes the model to:
- Think the tool failed when it actually succeeded
- Lose momentum on multi-step tasks
- Require manual retry of the same command
- Confuse the user ("did you get stuck?")
Current behavior
When a tool result is missing, the model receives the error string and must manually decide to retry. There is no automatic retry mechanism. The user sees a pause followed by an error message and has to prompt the model to continue.
Proposed solution
Add an automatic retry mechanism for tool calls that return internal errors:
- Transparent retry — If a tool result comes back as
[Tool result missing due to internal error], automatically retry the tool call 1-2 times before surfacing the error to the model. - Idempotency awareness — For non-idempotent tools (Write, Edit), check if the operation already succeeded (e.g., file exists with expected content) before retrying.
- Configurable — Allow users to set retry behavior in
settings.json:
``json``
{
"toolRetry": {
"enabled": true,
"maxRetries": 2,
"retryableErrors": ["Tool result missing due to internal error"]
}
}
Context
This issue is most noticeable during:
- Long sessions with 50+ tool calls
- Parallel agent execution (multiple subagents using tools simultaneously)
- Heavy Write/Bash tool usage
- Sessions using multiple MCP servers
Environment
- Claude Code on Windows 11 (Git Bash shell)
- Opus 4.6 model
- Heavy tool usage (settings.json with 100+ permission rules, 7 hooks, 11 plugins)
---
🤖 Generated with Claude Code
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗