-
-
Notifications
You must be signed in to change notification settings - Fork 57.2k
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
When a session transcript becomes corrupted with an orphan tool_result block (missing corresponding tool_use), the session becomes permanently broken until manually cleared.
Error message:
400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.24.content.1: unexpected \`tool_use_id\` found in \`tool_result\` blocks: toolu_XXXXX. Each \`tool_result\` block must have a corresponding \`tool_use\` block in the previous message."}}
This can happen when:
- Context truncation removes a
tool_usebut keeps itstool_result - Network errors during tool execution
- Other edge cases that corrupt the message history
Current Workaround
Manually delete the session transcript file:
rm /data/.clawdbot/agents/main/sessions/<session-id>.jsonlProposed Solution
Add an error handler that:
- Detects this specific error type when it occurs
- Auto-clears the corrupted transcript
- Notifies via configured channel (e.g., Slack #alerts)
- Retries the original message with a fresh session
This would make OpenClaw self-healing for this class of errors.
Alternative
At minimum, a CLI command to reset a specific session would help:
openclaw session reset <session-key>Environment
- OpenClaw version: 2026.2.1
- Running on Railway
- Multiple Slack channels as sessions
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request