Skip to content

fix(goal-loop): resume auto-continue after session compaction - #58

Merged
willytop8 merged 3 commits into
willytop8:mainfrom
harryzhou2000:fix/auto-continue-after-compaction
Aug 7, 2026
Merged

fix(goal-loop): resume auto-continue after session compaction#58
willytop8 merged 3 commits into
willytop8:mainfrom
harryzhou2000:fix/auto-continue-after-compaction

Conversation

@harryzhou2000

Copy link
Copy Markdown
Contributor

What changed

Fixes the goal loop stalling after session compaction: auto-continue now resumes on the next idle instead of waiting for a user nudge.

Root cause: claimContinuationSource dedupes continuations by claiming the source assistant turn it continues from. When a compaction interrupts an in-flight continuation, the recent message tail can still end on that same pre-compaction assistant message, so after compaction the claim matched again and the idle driver returned early forever — the goal stayed "running" but never continued.

Fix: the session.compacted handler now invalidates goal.continuationClaim, so the post-compaction idle issues a fresh continuation against the compacted context (the claim's dedupe purpose does not apply across a compaction boundary).

Why

The plugin disables OpenCode's generic post-compaction auto-continue while a goal is active (experimental.compaction.autocontinueenabled: false) to avoid two continuations racing, and relies on its own idle-triggered loop instead. That handoff broke when the stale claim survived the compaction.

Checks run

  • node test/goal-plugin.test.js — 308/308 pass, including the new reproduction test (auto-continue fires after compaction despite a pre-compaction continuation claim), which fails on main (0 continuations) and passes with the fix (exactly 1).
  • npm run check on official Node 22 — 385/385 pass.
  • CHANGELOG updated.

harryzhou2000 and others added 3 commits August 7, 2026 19:35
After a compaction the recent message tail can still end on the same
assistant message that an in-flight continuation claim points at, so the
idle driver's claim dedupe suppressed the post-compaction continuation and
the goal loop stalled until the user nudged it. Invalidate the continuation
claim on session.compacted so the next idle issues a fresh continuation
against the compacted context.

Adds a reproduction test: claim set for the latest assistant turn, then
session.compacted, then idle -> exactly one continuation prompt.
@willytop8
willytop8 merged commit deeb849 into willytop8:main Aug 7, 2026
10 checks passed
@willytop8 willytop8 mentioned this pull request Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants