Fix: Preserve completed subagent state across compactions
Subagent results were lost during context compaction, causing the model to re-launch already-completed research agents after compact.
What was fixed
Three bugs in the session continuity module:
extractSubagentignoredtool_response— only the prompt was captured, so the model had no record of completion- Missing
renderSubagents()function — subagent events were collected but never serialized into the resume snapshot XML - Subagent events not wired into snapshot tiers — completed agents now go to P2 (35% budget), launched agents to P3 (15% budget)
Result
After compaction, the resume snapshot now includes:
<subagents>
<agent status="completed">[completed] Research Cursor → Found env vars</agent>
<agent status="completed">[completed] Research Codex → Found CLI flags</agent>
</subagents>The model sees completed agents and does not re-launch them.
Tests
- 8 new tests across
session-extract.test.tsandsession-snapshot.test.ts - 713/713 tests passing, 0 failures
- End-to-end pipeline verified with programmatic verification