-
-
Notifications
You must be signed in to change notification settings - Fork 69.2k
[Bug]: Session corruption: orphaned tool_result after interrupted request + compaction #15691
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Summary
Session transcripts become corrupted with orphaned tool_result blocks after a request is interrupted and later compacted. This causes the Anthropic API to reject all subsequent requests with:
messages.X.content.Y: unexpected tool_use_id found in tool_result blocks: toolu_XXXX. Each tool_result block must have a corresponding tool_use block in the previous message.
Environment
- Clawdbot version: 2026.1.24-3
- OS: Ubuntu Linux (AWS)
- Model: claude-opus-4-5
- Multi-agent setup: 2 agents
Reproduction
- Run a long session with many tool calls (600+)
- Interrupt a request mid-tool-execution
- Clawdbot inserts synthetic tool_result for transcript repair
- Continue until context compaction triggers
- After compaction, tool_use is removed but synthetic tool_result remains
- API rejects all future requests
Frequency
Occurred 2 times in 2 days. 28 deleted session files suggest repeated occurrences.
Workaround
Delete the .jsonl transcript file and restart gateway. Agent loses history but workspace files intact.
Suggested Fix
During compaction, ensure tool_result blocks have matching tool_use preserved, or remove orphaned tool_results.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Fields
Give feedbackNo fields configured for issues without a type.