Bug Report
Version: 2026.3.7 (updated from 3.2 earlier today)
Platform: macOS (Darwin 25.3.0, arm64), Node v25.7.0
Model Provider: Anthropic (Claude Opus 4.6)
Summary
After a hook-triggered compaction, the API message reconstruction drops tool_result blocks while preserving their corresponding tool_use blocks. This creates a permanently malformed conversation history — every subsequent API call fails with:
messages.97: `tool_use` ids were found without `tool_result` blocks immediately after: call70362952. Each `tool_use` block must have a corresponding `tool_result` block in the next message.
The session becomes permanently unrecoverable. The only fix is /new or /reset, which loses the entire conversation.
Reproduction
This happened twice in one day on the same agent, both times after heavy sessions (~180K tokens) triggered hook-based compaction.
Sequence of events:
- Session reaches high token count (~180K tokens before compaction)
- Hook-triggered compaction fires (
fromHook: true in compaction entry)
- Compaction completes — JSONL data is intact (both
tool_use and tool_result entries are present and correctly linked via toolCallId)
- Next API request to Anthropic fails: the reconstructed messages array includes the
tool_use block but drops its matching tool_result
- Every subsequent message fails with the same error — session is permanently dead
- From the user's perspective: ~1 hour of Discord messages "disappear" and the bot starts posting error messages
JSONL forensics:
- Line 529: Assistant message with
tool_use blocks: memory_search(call_70362952) and session_status(call_03536860)
- Line 530:
toolResult with toolCallId: call_70362952 (memory_search result) ✅ exists
- Line 531:
toolResult with toolCallId: call_03536860 (session_status result) ✅ exists
- Line 523: Compaction event (
firstKeptEntryId: 36559378, tokensBefore: 180355)
- Line 535: First failed assistant response — empty content,
stopReason: "error"
The data integrity is fine. The bug is in how the kept entries are serialized into the Anthropic API messages array after compaction.
Suspected Cause
The 2026.3.7 release includes postCompactionSections — a new feature that modifies what gets injected after compaction. This is the exact code path where the tool_use/tool_result pairing breaks. Both occurrences today happened after updating to 2026.3.7; this was not observed on 2026.3.2.
Impact
High / Disruptive:
- Complete session loss (all conversation context gone)
- No graceful recovery — must
/new or /reset
- User-visible: messages "disappear" from Discord timeline
- Happened 2x in one day on a single agent
- Any session that reaches compaction threshold is at risk
Environment
- Agent:
big-brain (primary agent, Opus 4.6)
- Channel: Discord
- Compaction trigger: hook-based (automatic, not manual)
- Session JSONL preserved as
.reset file for inspection
Workaround
None currently. /new or /reset is the only recovery, which loses all session context.
Bug Report
Version: 2026.3.7 (updated from 3.2 earlier today)
Platform: macOS (Darwin 25.3.0, arm64), Node v25.7.0
Model Provider: Anthropic (Claude Opus 4.6)
Summary
After a hook-triggered compaction, the API message reconstruction drops
tool_resultblocks while preserving their correspondingtool_useblocks. This creates a permanently malformed conversation history — every subsequent API call fails with:The session becomes permanently unrecoverable. The only fix is
/newor/reset, which loses the entire conversation.Reproduction
This happened twice in one day on the same agent, both times after heavy sessions (~180K tokens) triggered hook-based compaction.
Sequence of events:
fromHook: truein compaction entry)tool_useandtool_resultentries are present and correctly linked viatoolCallId)tool_useblock but drops its matchingtool_resultJSONL forensics:
tool_useblocks:memory_search(call_70362952)andsession_status(call_03536860)toolResultwithtoolCallId: call_70362952(memory_search result) ✅ existstoolResultwithtoolCallId: call_03536860(session_status result) ✅ existsfirstKeptEntryId: 36559378,tokensBefore: 180355)stopReason: "error"The data integrity is fine. The bug is in how the kept entries are serialized into the Anthropic API messages array after compaction.
Suspected Cause
The 2026.3.7 release includes
postCompactionSections— a new feature that modifies what gets injected after compaction. This is the exact code path where the tool_use/tool_result pairing breaks. Both occurrences today happened after updating to 2026.3.7; this was not observed on 2026.3.2.Impact
High / Disruptive:
/newor/resetEnvironment
big-brain(primary agent, Opus 4.6).resetfile for inspectionWorkaround
None currently.
/newor/resetis the only recovery, which loses all session context.