Skip to content

[Bug] Session corruption with orphaned tool_use blocks when using gateway tool with Anthropic provider #3528

@limace11

Description

@limace11

Description

When using the gateway tool to modify configuration mid-conversation with Claude Sonnet 4.5 or Opus 4.5, the session becomes corrupted. Subsequent messages fail with:

LLM request rejected: messages.X: tool_use ids were found without tool_result blocks immediately after: call_XXXXXXXX

Steps to Reproduce

  1. Configure clawdbot with anthropic/claude-sonnet-4-5 as primary model
  2. Start a conversation via WhatsApp
  3. Ask the bot to modify its own configuration (triggers gateway tool)
  4. Send another message after the config change completes

Expected Behavior

The conversation should continue normally after configuration changes.

Actual Behavior

The session file contains orphaned tool_use blocks without matching tool_result blocks, causing the Anthropic API to reject the request.

Logs

17:44:28 tool start: gateway toolCallId=call_48325266
17:44:28 tool end: gateway toolCallId=call_48325266
17:48:19 LLM request rejected: messages.55: tool_use ids were found without tool_result blocks immediately after: call_48325266

Workaround

Delete session files after the error occurs:

rm ~/.clawdbot/agents/main/sessions/*.jsonl
clawdbot gateway restart

Environment

  • Clawdbot version: 2026.1.24-3
  • Provider: Anthropic (claude-sonnet-4-5)
  • Channel: WhatsApp
  • OS: Ubuntu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions