Compaction mode safeguard corrupts conversation history when context reaches ~78%. Removes tool_use blocks but leaves orphan tool_result blocks, causing API error: unexpected tool_use_id found in tool_result blocks
Bug Report: Compaction breaks tool_use/tool_result pairing
Version: 2026.1.24-3 (885167d)
Environment:
OS: Ubuntu 24 (linux 6.8.0-90-generic x64)
Node: 22.22.0
Model: claude-opus-4-5 (200k context)
Install: pnpm
Channel: stable
Configuration:
json"compaction": {
"mode": "safeguard"
}
**Symptoms:**
- Session reaches ~78% context (157k/200k tokens)
- Subsequent messages fail with API error
- Error returned to user via channel
**Error message:**
LLM request rejected: messages.406.content.1: unexpected tool_use_id found in tool_result blocks: toolu_XXXXX. Each tool_result block must have a corresponding tool_use block in the previous message.
warn agent/embedded Profile anthropic:default hit Cloud Code Assist format error. Tool calls will be sanitized on retry.