Repository navigation
feat(pi): drain and resume pi() runs - #327
Merged
eersnington merged 4 commits intoOct 5, 2026
Merged
Conversation
This was referenced Oct 5, 2026
eersnington
force-pushed
the
stack/feat-pi-drain-and-resume-pi-runs-rklvtvuy
branch
from
October 5, 2026 09:54
a5f611c to
e52d027
Compare
eersnington
force-pushed
the
stack/chore-pi-bump-pi-coding-agent-to-1-0-2-tvmyommk
branch
from
October 5, 2026 09:54
190ad8f to
6e58b4b
Compare
eersnington
force-pushed
the
stack/chore-pi-bump-pi-coding-agent-to-1-0-2-tvmyommk
branch
from
October 5, 2026 18:53
6e58b4b to
f2bb142
Compare
eersnington
force-pushed
the
stack/feat-pi-drain-and-resume-pi-runs-rklvtvuy
branch
from
October 5, 2026 18:53
e52d027 to
3f69319
Compare
eersnington
merged commit Oct 5, 2026
90587b2
into
stack/chore-pi-bump-pi-coding-agent-to-1-0-2-tvmyommk
1 of 3 checks passed
eersnington
deleted the
stack/feat-pi-drain-and-resume-pi-runs-rklvtvuy
branch
October 5, 2026 19:13
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.
pi()gets the same deploy behavior aspiDurable(): live runs drain, and a run cut off by a stop resumes on wake when Pi can continue it.session.abort(), the run ends as abortedsleepGracePeriod(15 min default)c.abortSignalprompttimes out, or its caller leavespromptrejects, and the run keeps going. Only theabortaction stops itDrain and lost generations
onSleepand keeps time back for closing (drainDeadlineinsrc/drain.ts), so the final save and the sandboxsuspendrun before RivetKit's grace deadline.onSleep, sostopRunWhenLostlistens on the actor's abort signal fromonWakeand aborts the run when the context reportsisLost. Otherwise the old process keeps calling the model and running tools next to the generation that resumed the run. RivetKit releases without lost generations still runonSleep, and the drain handles them.When a run resumes
Resume never writes an entry Pi would not write. It continues only when Pi's own
Agent.continue()accepts the stored transcript: the last message is a user or tool-result message.abortranA chat that does not resume is left as after an abort, and the next message continues it.
How
run_stateandqueued_jsontopi_session. A run start recordsrunningand the queued steer and follow-up messages; the end recordsidle.onWake,resumeInterruptedRunreplays the queue and drivesAgentSession's own run loop, so retry, compaction, and queued messages work as in any run:pi-coding-agentis pinned exactly, and the resume test fails if an upgrade changes them.c.keepAwake. A client that was waiting onpromptwhen the actor stopped got an error; it sees the finished run through events orgetMessages().This is part 8 of 11 in a stack: