Repository navigation
fix(runtime): record a turn a quit cuts off as interrupted, not as a Stop (ATO-1688) - #1761
Closed
sosidudku1 wants to merge 3 commits into
Closed
sosidudku1 wants to merge 3 commits into
sosidudku1 wants to merge 3 commits into
Conversation
…Stop (ATO-1688) serve dropped its connections before runtime.shutdown, which aborted the turns on them. A turn that unwound in that moment wrote its own end as a plain cancel, over the shutdown's interrupted stand-in, so the chat reopened with no word that its reply was cut off and no Continue. The runtime now has beginShutdown (called by serve before it drops the connections) and isStopping; a turn that ends cancelled while the host stops ends with INTERRUPTED_TURN_ENDING, transcript kept as written.
…r a task's (ATO-1688) Review: shutdown alone set the flag, so a host that stops its own turn and then shuts down (the TUI's quit, and the tests that pin it) had that end overwritten. Now only beginShutdown sets it. A durable task's turn keeps its own end: the task runner runs it again, and Continue on its chat would have nothing to continue. Tests drive isStopping directly.
Collaborator
Author
|
Merged into |
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.
Fixes ATO-1688 (agent side). Reported in Discord: a chat working in the background was killed when the desktop app quit, and after relaunch the chat gave no sign that its reply had been cut off.
Cause
servecloses its HTTP server beforeruntime.shutdown(). Closing drops the connections, which aborts the turns on them. A turn that unwound in that moment ran its normal cancel path and wrote its end as a plaincancelledwith the error it had before, the same as a person pressing Stop. That overwrote the interrupted stand-in shutdown writes (or came before it), sointerruptedChatTurn(ATO-448) saw no interrupted ending: no "reply was cut off" line and no Continue in the desktop, no/resumehint in the TUI.Change
createRuntimeLifecyclegetsbeginShutdown()andisStopping(). OnlybeginShutdownsets it: a host that stops its own turn and then callsshutdown(the TUI's quit) keeps that turn's own end, as before.AgentRuntime.beginShutdown?()(optional), wired inbootstrap.ts.servecalls it first thing in its teardown, before it drops the connections.runtime-turn-service.ts: a chat turn that endscancelledwhile the host is stopping is saved withINTERRUPTED_TURN_ENDING(transcript kept as the turn wrote it, progress marker kept as for any cancel). A thrown turn aborted while stopping is released withINTERRUPTED_TURN_ENDINGinstead of the prior error. A person's Stop with the host running is unchanged. A durable task's turn (checkpoint.taskId) keeps its own end: the task runner runs it again, and Continue on its chat would have nothing to continue.Tests
runtime-lifecycle.test.ts:isStoppingfrombeginShutdownon, and not fromshutdownalone.runtime-turn-service.test.ts: cancelled while stopping ends interrupted with its transcript; a Stop, with the host running or only shutting down, stays a plain cancel; a task turn keeps its own end; a thrown abort while stopping is released interrupted.The desktop half (quit dialog, sidebar) is the companion PR on
rel/xp-build, which also carries this commit.Verification
shutdownalone set the flag and broke the TUI-quit contract pinned inbootstrap-turn-status.test.ts,bootstrap-task-lifecycle.test.ts; task turns got a Continue offer that could not continue.beginShutdownbeforehandle.close()(one line inserve-command.ts).