Summary
When a session transcript becomes corrupted (orphaned tool_result without matching tool_use), the raw Anthropic API error is delivered directly to the chat surface instead of being handled gracefully.
Reproduction
- A session accumulates tool calls over time
- Context compaction or a crash leaves a
tool_result block without its corresponding tool_use
- Every subsequent message to that session fails with:
LLM request rejected: messages.144.content.1: unexpected tool_use_id found in tool_result blocks: toolu_01HjX9c7NLJaBLDzyBasSkKw. Each tool_result block must have a corresponding tool_use block in the previous message.
- This error is sent to the Telegram group (or other surface) on every message — effectively spamming the channel
Observed behavior
- Session:
agent:main:telegram:group:-1003892537872:topic:37
- Transcript:
3bd7214b-ada2-42fa-b07e-8ad3d15fd308.jsonl (84 entries)
- Error referenced message index 144 (API-side count after expansion)
Expected behavior
- Don't expose raw API errors to users — log them, maybe notify the admin, but don't spam the chat
- Self-heal when possible — detect orphaned tool_results and either:
- Prune them from context before sending
- Or reset the session automatically with a single notice
- Prevent corruption — ensure compaction never orphans tool_result blocks
Workaround
Manual fix: delete/move the corrupted session transcript. Next message starts fresh.
mv ~/.openclaw/agents/main/sessions/<session-id>.jsonl ~/.Trash/
Environment
- OpenClaw 2026.2.1 (ed4529e)
- Model: claude-opus-4-5
- Surface: Telegram group with topics
Summary
When a session transcript becomes corrupted (orphaned
tool_resultwithout matchingtool_use), the raw Anthropic API error is delivered directly to the chat surface instead of being handled gracefully.Reproduction
tool_resultblock without its correspondingtool_useObserved behavior
agent:main:telegram:group:-1003892537872:topic:373bd7214b-ada2-42fa-b07e-8ad3d15fd308.jsonl(84 entries)Expected behavior
Workaround
Manual fix: delete/move the corrupted session transcript. Next message starts fresh.
Environment