-
-
Notifications
You must be signed in to change notification settings - Fork 57.1k
Description
OpenClaw's transcript repair mechanism attempts to fix missing tool results by inserting synthetic errors, but creates a tool_use/tool_result ID mismatch that permanently breaks the session. Even openclaw session reset cannot recover - only manual deletion of session files works.
Steps to reproduce
- Experience a tool result loss (network interruption, gateway restart, or timing issue during tool execution)
- OpenClaw detects missing result and logs: [openclaw] missing tool result in session history; inserted synthetic error result for transcript repair.
- Send any new message to the session
- Observe: Every request fails with 400 error about unexpected tool_use_id
Expected behavior
When inserting synthetic error results, OpenClaw should:
• Verify the corresponding tool_use block exists in the previous message
• Skip synthetic insertion if tool_use is missing (fail gracefully)
• OR reconstruct the full tool_use/tool_result pair correctly
• Validate the repair before persisting to session file
Actual behavior
- Synthetic repair creates tool_result referencing a tool_use_id that doesn't exist in the previous message
- Session becomes permanently broken
- Every subsequent request (including openclaw session reset) fails with same error:
HTTP 400 invalid_request_error: messages.254.content.1: unexpected tool_use_id found in tool_result blocks: toolu_01H4RzKvgMZxs7diWx2VX9FS. Each tool_result block must have a corresponding tool_use block in the previous message. - Only fix is nuclear: rm -rf ~/.openclaw/sessions/main
Environment
• OpenClaw version: 2026.2.3 (latest)
• OS: macOS Darwin 25.2.0 (arm64)
• Install method: npm global install
• Node: v22.22.0
• Model: anthropic/claude-sonnet-4-5
• Session: main (webchat)
Logs or screenshots
Session Log Pattern:
🛠️ Exec {} [openclaw] missing tool result in session history; inserted synthetic error result for transcript repair.
terminated
Error (repeated on every message):
HTTP 400 invalid_request_error: messages.254.content.1: unexpected tool_use_id found in tool_result blocks: toolu_01H4RzKvgMZxs7diWx2VX9FS. Each tool_result block must have a corresponding tool_use block in the previous message. (request_id: req_011CXm7oRsUVsBoVoKoAmqW8)
Workaround:
Backup first (CRITICAL)
cp -r ~/.openclaw/sessions ~/.openclaw/sessions_backup_$(date +%Y%m%d_%H%M%S)
Nuclear option - clear the corrupted session
rm -rf ~/.openclaw/sessions/main
Restart gateway
openclaw gateway restart
Related Issues
• #7659 - Feature Request: Auto-recovery for corrupted session transcripts
• #5430 - Session Corruption Bug: Terminated Tool Calls
• #5857 - Malformed tool_use blocks corrupt session history
This is a variant where the repair mechanism itself creates corruption.