Repository navigation
[REA-6854] Close a session when it reaches its steps - #235
Merged
Merged
Conversation
This was referenced Oct 3, 2026
Contributor
Author
This was referenced Oct 3, 2026
Dere-Wah
force-pushed
the
dere/rea-6854-close-the-session-at-steps
branch
from
October 3, 2026 19:54
af1b177 to
c0f4bc9
Compare
Dere-Wah
force-pushed
the
dere/rea-6854-report-completed-steps
branch
from
October 3, 2026 19:54
9af1f4c to
9faa1ed
Compare
This was referenced Oct 3, 2026
tempusfrangit
approved these changes
Oct 3, 2026
tempusfrangit
left a comment
Contributor
There was a problem hiding this comment.
Reviewed completion counting, stop notifications, and default-loop session stamping. The regression coverage verifies that an earlier session's report cannot stop a later session.
Dere-Wah
force-pushed
the
dere/rea-6854-close-the-session-at-steps
branch
from
October 4, 2026 16:39
c0f4bc9 to
8c05792
Compare
Dere-Wah
force-pushed
the
dere/rea-6854-report-completed-steps
branch
2 times, most recently
from
October 4, 2026 18:28
2b9b4f5 to
dc34d85
Compare
Dere-Wah
force-pushed
the
dere/rea-6854-close-the-session-at-steps
branch
from
October 4, 2026 18:28
8c05792 to
b00b1d3
Compare
Dere-Wah
force-pushed
the
dere/rea-6854-report-completed-steps
branch
from
October 4, 2026 23:47
dc34d85 to
c52f4ed
Compare
Dere-Wah
force-pushed
the
dere/rea-6854-close-the-session-at-steps
branch
from
October 4, 2026 23:47
b00b1d3 to
686e937
Compare
ggoldens
reviewed
Oct 5, 2026
ggoldens
approved these changes
Oct 5, 2026
Dere-Wah
force-pushed
the
dere/rea-6854-close-the-session-at-steps
branch
from
October 5, 2026 17:58
686e937 to
7aaeb4d
Compare
Dere-Wah
force-pushed
the
dere/rea-6854-report-completed-steps
branch
from
October 5, 2026 17:58
c52f4ed to
91cdf36
Compare
Contributor
Author
Dere-Wah
changed the base branch from
dere/rea-6854-report-completed-steps
to
graphite-base/235
October 5, 2026 18:17
A session started with a step count is meant to run that many steps and end, with no client there to stop it. The runtime counts the steps the model reports, and the step that brings a running session to its count stops it: a normal stop with the close reason "Session ended: the requested steps are complete.", which connected clients are told before their connections close. The model keeps stepping until the session end reaches it, so a step reported after the stop is journalled with its number and stops nothing. A session without a step count never stops on its own. The contract suite now runs the whole flow on a model with no client connected: the system client opens, the starting command runs, two steps complete, and the session closes itself back to ready. Signed-off-by: Dere-Wah <derexcontact@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
A step report carried nothing that tied it to a session, and the step count resets when a session starts. A model that finished a unit of work just after a quick stop and restart therefore had that report counted against the new session, and could close it early. Each report now carries the session it belongs to: the number of session starts the model had received, which the runner counts the same way as it posts them. The default step loop stamps the session a step began in, so a step that spans a restart is not credited to the next session. The runner drops a report from any other session without journalling or counting it. Signed-off-by: Dere-Wah <derexcontact@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
A session that starts with steps and a starting input naming an upload the caller seeds only after the start must not count a step on the defaults the starting input replaces, nor reach its steps before its setup arrives. The contract suite now runs that flow end to end: the image is uploaded 200 ms after the start, and the journal shows the starting command before the first step_completed, then the stop. Signed-off-by: Dere-Wah <derexcontact@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
The README described a session with steps as streaming until it ends, without saying the runtime ends it once the model has reported that many steps. One sentence now says so, with the close reason clients are told. Signed-off-by: Dere-Wah <derexcontact@gmail.com> Co-authored-by: Cursor <cursoragent@cursor.com>
Dere-Wah
force-pushed
the
dere/rea-6854-close-the-session-at-steps
branch
from
October 5, 2026 18:20
7aaeb4d to
62019ed
Compare
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.

Why
A session started with
stepsis meant to run that many steps and end, and there may be no client there to stop it. With step reports in place, the runtime can close the session itself.What Changed
The step that brings a running session to its
stepsstops it with a normal stop: reasonstoppedand the close reason "Session ended: the requested steps are complete.", which connected clients are told before their connections close. The model keeps stepping until the session end reaches it, so a step reported after the stop is journalled with its number and stops nothing. A session withoutstepsnever stops on its own.A step report carries the session it began in, as the model's count of session starts, and the runner keeps the same count of the starts it posts. A report from an earlier session, one that a model finishes after a quick stop and restart, is dropped: it is neither journalled nor counted, so it cannot close the session that followed.
The contract suite now runs the whole flow on a model with no client connected, with the orphan timeout set short so a client-less timeout would show up if it fired:
A second contract test starts a session with
steps: 2whose starting input names an image the caller uploads 200 ms after the start. The journal shows the starting command before the firststep_completed, so a session cannot reach its steps before its setup arrives.The same flow against
examples/starterwithsteps: 5and no client ran five steps, stopped, and returned toready; one more step was reported before the session end reached the model, and it was journalled without effect.