fix(strategy): preserve cumulative subagent baseline across condensation backfill

main

Commit

suhaanthayyil2mo ago

During condensation, sessionStateBackfillTokenUsage overwrote state.TokenUsage with a value recomputed from the transcript with subagentsDir="", which drops SubagentTokens. resetCheckpointWindow then captured the next window's baseline from state.TokenUsage.SubagentTokens — now nil — so the next checkpoint re-reported the full cumulative subagent total. This fired on every real condensation (Claude Code transcripts always carry usage lines, so the backfill's InputTokens>0 branch always ran).

Preserve the authoritative cumulative subagent total (accumulated by SaveStep) across the backfill, folded onto a copy so it is never mixed into the checkpoint-scoped value written to metadata. The regression test now uses a usage-bearing transcript so it exercises the real backfill path instead of passing vacuously.