-
-
Notifications
You must be signed in to change notification settings - Fork 40.1k
Closed
Description
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
- Hit rate limits on primary model (e.g., Antigravity quota exhausted)
- Failover cascade through multiple models, all rate-limited
- Request fails mid-tool-use
- Session file now contains malformed tool_use entry (missing
input/argumentsfield) - All future requests to this session fail with the above error
- 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 restartSuggested Fixes
- Validate session entries on write — reject/repair malformed tool_use blocks before persisting
- Validate on read — skip or repair malformed entries when loading session history
- Atomic writes — ensure session file updates are atomic to prevent partial writes
- 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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels