Skip to content

[Bug]: Malformed tool_use blocks corrupt session history, causing permanent blank responses #5857

@knetur

Description

@knetur

Summary

When a tool call is interrupted or fails in a specific way, OpenClaw saves a malformed tool_use block to the session history (missing the required input field). This corrupts the session permanently — all subsequent requests fail with a validation error from Claude's API, resulting in blank responses.

Steps to reproduce

  1. Use OpenClaw with a Claude model via the Antigravity provider
  2. Trigger multiple tool calls (e.g., browser automation, exec commands)
  3. During a tool call, interrupt the process (timeout, network issue, or manual interruption)
  4. The tool call gets saved to the session .jsonl file with a malformed structure
  5. Send any new message — it will "think" but return a blank response
  6. Check the session file or logs for the error: messages.X.content.Y.tool_use.input: Field required

Expected behavior

  • OpenClaw should validate tool call structures before saving to the session file
  • Malformed tool calls should not be persisted
  • If a corrupted message exists, OpenClaw should detect and recover (or at least warn the user)

Actual behavior

  • Malformed tool_use block is saved to session (missing input field)
  • Every subsequent API request includes the corrupted history
  • Claude API rejects with: messages.X.content.Y.tool_use.input: Field required
  • User sees "thinking" indicator but blank response
  • Error cascades — each retry adds another error message to the session, making it worse

Environment

  • OpenClaw version: 2026.1.29
  • OS: macOS 26.2 (arm64)
  • Install method: npm (npm i -g openclaw@latest)
  • Model: google-antigravity/claude-opus-4-5-thinking
  • Node: v24.8.0

Logs or screenshots

Error in session file:

messages.237.content.1.tool_use.input: Field required

Corrupted message structure (note missing input on second toolCall):

{
  "id": "e775c1a3",
  "message": {
    "role": "assistant",
    "content": [
      {"type": "text", "text": "..."},
      {"type": "tool_use", "id": "toolu_123", "name": "browser", "input": {...}},
      {"type": "tool_use", "id": "toolu_456", "name": "exec"}
    ]
  }
}

Note: The second tool_use block is missing the required input field.

Frequency: Happened twice in one day during normal usage (browser automation and exec commands).

Workaround

Manually repair the session file by removing the corrupted message and all descendants:

# Find the corrupted line and truncate the session
# Backup first, then remove from the corrupted message onwards

Suggested Fix

  1. Validate before saving: Check that all tool_use blocks have required fields (id, name, input) before persisting to the session file
  2. Graceful recovery: If API returns this specific validation error, auto-rollback to last known good state
  3. Session checkpoints: Periodic snapshots that can be restored

This issue was identified with AI assistance (Claude via OpenClaw). The analysis and reproduction steps have been verified by the user.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions