Skip to content

fix(desktop): let a queued turn request compaction after a requested one - #4351

Merged
LHagfoss merged 1 commit into
mainfrom
fix/desktop-requested-compaction-queue
Nov 25, 2026
Merged

LHagfoss merged 1 commit into
mainfrom
fix/desktop-requested-compaction-queue

Conversation

@LHagfoss

Copy link
Copy Markdown
Owner

What

An agent that called compact_thread with resume: true could stop for good instead of compacting and carrying on.

When the requested /compact turn ends, runPrompt starts the next message in the thread's queue (a PR or delegate wake, for example) and waits for that turn too before it returns. The "a compaction is running" guard was only cleared when runPrompt returned, so while the queued turn ran, any new compact_thread call from it was refused with "a compaction is already requested for this thread". The turn then ended with nothing scheduled, and the thread sat idle.

Seen live: a long PR-by-PR run compacted after each PR, a PR-checks wake arrived during one compaction, the agent's next compact_thread was refused, and the run stopped.

  • The guard is now cleared as soon as the /compact turn itself ends (requestedCompactionEnded), so a queued turn can request the next compaction. That request runs when the queued turn ends and continues as usual.
  • The .finally in runRequestedCompaction still clears the guard on paths that return early.

Changelog

Agents that compact and continue no longer stop when a wake arrives during their compaction.

Testing

  • New store test: a turn queued behind a requested compaction requests another; it is accepted, both compactions run and the thread continues. Without the fix the test fails on the refused request.
  • autoCompact.store.test.ts passes (25 tests). bunx tsc, biome, bunx vite build and check-comments.py pass. bun run check fails only on the known flaky stopTrace.store.test.ts ("a harness that ignores the Stop is forced").

@github-actions github-actions Bot added the fix A bug fix label Nov 25, 2026
@LHagfoss
LHagfoss merged commit cb55eed into main Nov 25, 2026
10 checks passed
@LHagfoss
LHagfoss deleted the fix/desktop-requested-compaction-queue branch November 25, 2026 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant