Repository navigation
fix(acp): recover saved sessions on the execution host - #4030
Merged
Merged
Conversation
Keep admitted turns and their output on the host until terminal history is saved. Reopen the original agent session to repair missing history, using message IDs or a unique alignment of saved prompts to place replies. Retire an admitted turn on release before its prompt can reach the agent.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This fixes the remaining session recovery problems reported in #3923, which is already closed. A running ACP turn could already reappear when switching back to its view. Output accepted while the view was detached could still be missing from saved history, and reconnecting could leave those gaps in place.
The executing host now keeps each admitted turn across view switches, journals its text, thoughts and tool events, and retains them until the terminal turn is saved to conversation history. Reopening reads the saved transcript and the host's execution state. When history has a gap, the host loads the original agent session and assigns replayed replies by message ID or, for older sessions, by a unique ordered match against the prompts actually sent. Ambiguous replies leave the gap open. Releasing the session during agent startup or history loading prevents an admitted prompt from being sent.
Verification
client::manager::recovery_testsexercise legacy reopen, interrupted history, reply ownership for repeated prompts and release before send.node tests/e2e/scripts/run-acp-queue-recovery.mjspassed all 10 scenarios with a controlled ACP agent over stdio. It verified that a view switch preserves the running prompt, a reload drains its queue once, and an agent exit reconnects and drains the follow-up.