fix(session): close turns left open by a process that died - #113
Merged
Conversation
Only one run exists per session at a time, so an assistant message still open when a fresh run starts was left by a run that no longer exists. Until now nothing closed it, and the TUI reads open as "a turn is in progress": every message typed afterwards was stamped QUEUED, across restarts, with nothing running behind it. A session that survived one OOM looked jammed forever. Close them on the way in, count them as an intervention so a week of these says the OOM came back, and stop the badge from calling an open message a queue when the session is idle. Claude-Session: https://claude.ai/code/session_014XwJPDhq1ahcm3rd454WzQ
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.
The complaint this answers
Two different failures were being treated as one. The live turn that stalls is covered by the
watchdog and the other guards in 0.14.0. This is the other one, and nothing addressed it.
time.completedon an assistant message is written by the process running the turn. When thatprocess is killed — an OOM (which this user hit repeatedly), a machine going to sleep, a crash —
nobody writes it. The message stays open forever.
The TUI computes its QUEUED badge purely from that:
So a session that survived one OOM stamps QUEUED on everything typed from then on, across
restarts, with no agent running. The server processes those messages perfectly well — nothing
gates on it — but the interface says the opposite, and there is no way for the user to tell it
apart from a real queue. There was no recovery of dangling messages anywhere: not on boot, not on
load, not on the next turn.
The fix, in two halves
time, and a turn interrupted while its process lives finalizes itself on the way out — so an open
message found at the start of a new run belongs to a run that is gone. It is marked aborted with
"The process ended before this turn finished." and recorded through the guard log from feat(session): record every guard intervention #112, so a
week of these says the OOM came back.
not a queue.
Verification
passing after: the message is closed with
MessageAbortedError, the turn still runs normally, andthe trip is counted under
orphan.finished.
packages/redcodesession suite 456 pass,packages/tui228 pass.https://claude.ai/code/session_014XwJPDhq1ahcm3rd454WzQ
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.