-
-
Notifications
You must be signed in to change notification settings - Fork 69.7k
Context corruption exposes raw API errors to chat surface #11038
Copy link
Copy link
Closed as not planned
Copy link
Labels
bugSomething isn't workingSomething isn't workingstaleMarked as stale due to inactivityMarked as stale due to inactivity
Description
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_resultblock without its correspondingtool_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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingstaleMarked as stale due to inactivityMarked as stale due to inactivity
Type
Fields
Give feedbackNo fields configured for issues without a type.