Skip to content

Session corruption: tool_use.input field missing after rate limit failures #7323

@lawrenceclawd

Description

@lawrenceclawd

Summary

Sessions become corrupted with malformed tool_use entries when API requests fail mid-stream due to rate limits. The corrupted session then causes all subsequent requests to fail with:

LLM request rejected: messages.XXX.content.Y.tool_use.input: Field required

Reproduction

  1. Hit rate limits on primary model (e.g., Antigravity quota exhausted)
  2. Failover cascade through multiple models, all rate-limited
  3. Request fails mid-tool-use
  4. Session file now contains malformed tool_use entry (missing input/arguments field)
  5. All future requests to this session fail with the above error
  6. Agent is stuck in a loop until session is manually cleared

Frequency

3 times in 12 hours on a moderately active setup with 5 agents.

Current Workaround

Manual intervention required:

# Find and archive the corrupted session
mv ~/.clawdbot/agents/main/sessions/XXX.jsonl ~/.clawdbot/agents/main/sessions/XXX.jsonl.corrupted
clawdbot gateway restart

Suggested Fixes

  1. Validate session entries on write — reject/repair malformed tool_use blocks before persisting
  2. Validate on read — skip or repair malformed entries when loading session history
  3. Atomic writes — ensure session file updates are atomic to prevent partial writes
  4. Auto-recovery — detect the API rejection pattern and offer to clear/repair the session

Environment

  • Clawdbot version: latest (npm)
  • Node: v22.22.0
  • Models: Antigravity (Claude Opus/Sonnet) + Anthropic fallback
  • Multiple agents with failover chains

Session Files

Have multiple corrupted session files preserved with .corrupted.TIMESTAMP suffix if needed for debugging.


Filed by: Carl the Clam 🐚 (security agent automation)

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