You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sessions could appear stuck after auto-compaction (or after a failed tool-call recovery) because post-compaction resume called agent.continue() directly and swallowed any failure, bypassing the retry/queue-draining lifecycle that a normal turn goes through. This routes post-compaction resume through the same continuation path as regular queued turns and surfaces failures instead of silently dropping them.
Added _runAgentContinue() (agent-session-prompt.ts) which calls agent.continue(), then waitForRetry(), then drains queued messages via _continueQueuedAgentMessages() — mirroring the lifecycle _runAgentPrompt() already uses for normal turns.
_resumeAfterAutoCompaction() now calls _runAgentContinue() instead of a bare agent.continue().catch(() => {}), so retries and queued follow-ups are no longer dropped after compaction.
Added an agent_continue_error session event (source: post_compaction) emitted when post-compaction continuation fails, instead of the error being swallowed.
Wired the new event into interactive mode (interactive-agent-events.ts shows the error and re-renders) and the chat-session host event reducer (chat-session-host-events.ts clears busy state and surfaces the status message).
Documented the resume behavior in packages/coding-agent/docs/compaction.md and added a changelog entry.
Added regression tests covering the full continuation lifecycle (continue → waitForRetry → queue drain) and visible failure surfacing on post-compaction resume.
Validation
AGENT=1 bun run --cwd packages/coding-agent test -- test/agent-session-auto-compaction-queue-01.suite.ts test/agent-session-auto-compaction-queue-02.suite.ts
AGENT=1 bun run typecheck
bun run check:file-length
pre-push hooks: bun run lint, bun run check:file-length, bun run test:unit
Code Review — PR #1574fix(compaction): resume queued work after compaction
Nice, tightly-scoped fix. Replacing the fire-and-forget agent.continue().catch(() => {}) with a real _runAgentContinue() that mirrors _runAgentPrompt() (continue → waitForRetry() → drain queued) is the right call — it reuses the established continuation lifecycle rather than reinventing it, and the failure surfacing directly addresses the "session looks dead" symptom in issue #1570. Type union, method-surface interface, agentSessionPromptMethods registration, docs, changelog, and tests are all updated consistently. 👍
Things worth a look
1. Removing .catch(() => {}) now surfaces previously-swallowed errors — confirm none are benign. In _schedulePostAutoCompactionContinuationProbe, the overflow && willRetry branch calls _resumeAfterAutoCompaction() even when hasQueuedMessages() is false. Previously any error from agent.continue() there was silently dropped; now every throw emits agent_continue_error, flips sdkBusy = false, and shows a red Post-compaction continuation failed: … to the user. Please double-check there is no edge case (e.g. "no active turn to continue", or a benign abort) where agent.continue() can reject in that path — otherwise this could turn a previously-invisible no-op into a scary user-facing error. If such benign rejections exist, consider filtering them before emitting.
2. source: "post_compaction" is defined but never read. The discriminant field on the event type is not consumed by either the interactive handler or the chat-session host (both only read errorMessage). Harmless as a forward-looking discriminator, but if it is not intended for imminent use it is dead weight; a short comment on its purpose would help.
3. Dual event handling (pre-existing, just flagging).agent_continue_error is handled in both chat-session-host-events.ts (statusMessage + clear sdkBusy) and interactive-agent-events.ts (showError). This matches how existing events like compaction_end/agent_end are dual-handled, so it is consistent with the architecture — just confirm these paths stay mutually exclusive so the error is not rendered twice in one UI. RPC forwarding is automatic via session.subscribe(... this.output(event)), and print-mode consumes assistant messages rather than granular events, so both are correctly covered without changes.
Test coverage. Good regression coverage: the two new queue-02 tests assert the full lifecycle (continue + waitForRetry + drain each called once) and that a rejected continue() produces exactly Post-compaction continuation failed: boom; the queue-01 additions assert the drain step now runs. One caveat — the tests mock out _continueQueuedAgentMessages, waitForRetry, and continue, so they verify the wiring rather than real end-to-end draining. That is reasonable for this fix, but an integration-style test that lets an actually-queued message drain through a real (stubbed-provider) continue would harden it against future refactors of the lifecycle.
Style / conventions. Matches CLAUDE.md — .ts-native, no build step touched, the Extract cast follows the existing String(event.type) switch pattern in the host file, and no any/unknown introduced. Changelog entry is descriptive and links the issue. LGTM overall pending the #1 sanity check.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Sessions could appear stuck after auto-compaction (or after a failed tool-call recovery) because post-compaction resume called
agent.continue()directly and swallowed any failure, bypassing the retry/queue-draining lifecycle that a normal turn goes through. This routes post-compaction resume through the same continuation path as regular queued turns and surfaces failures instead of silently dropping them.Closes #1570
Changes
_runAgentContinue()(agent-session-prompt.ts) which callsagent.continue(), thenwaitForRetry(), then drains queued messages via_continueQueuedAgentMessages()— mirroring the lifecycle_runAgentPrompt()already uses for normal turns._resumeAfterAutoCompaction()now calls_runAgentContinue()instead of a bareagent.continue().catch(() => {}), so retries and queued follow-ups are no longer dropped after compaction.agent_continue_errorsession event (source:post_compaction) emitted when post-compaction continuation fails, instead of the error being swallowed.interactive-agent-events.tsshows the error and re-renders) and the chat-session host event reducer (chat-session-host-events.tsclears busy state and surfaces the status message).packages/coding-agent/docs/compaction.mdand added a changelog entry.continue→waitForRetry→ queue drain) and visible failure surfacing on post-compaction resume.Validation
AGENT=1 bun run --cwd packages/coding-agent test -- test/agent-session-auto-compaction-queue-01.suite.ts test/agent-session-auto-compaction-queue-02.suite.tsAGENT=1 bun run typecheckbun run check:file-lengthbun run lint,bun run check:file-length,bun run test:unit