Repository navigation
fix(pi): stop waiting for pi 30s after an abort it can't settle - #154
Draft
jonnyparris wants to merge 5 commits into
Draft
jonnyparris wants to merge 5 commits into
jonnyparris wants to merge 5 commits into
Conversation
After a user abort or a turn stall, PiEngine.run waited on submission.wait with no bound and kept the event stream attached. A model request or tool that ignores the abort signal keeps pi's run alive, so run() never returned. Now it waits PI_ABORT_GRACE_MS (30s), then detaches, logs, and returns unanswered (abort_timeout). Known gap, documented: pi still queues the session's next prompt behind the orphan until it ends. Tests show close + reopen doesn't free it either. Also moves two watchdog Limitations bullets back under their heading.
…ly; accurate docs
…; tidy test cleanup and docs
…of the queued prompt
…up survives a failed abort
|
Preview deployed: https://dodo-preview.jonnyparris.club Serves The preview is shared: the next PR push replaces this build, and this PR gets a new comment when that happens. Add the Replaced |
|
Preview replaced: https://dodo-preview.jonnyparris.club now serves A live check on this PR that started before now is no longer testing this branch. Re-run this PR's deploy-preview job to take the preview back, or add the |
This branch was successfully deployed
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
Follow-up from #148 review round 3. After a user abort or a turn stall,
PiEngine.runawaitedsubmission.wait(this.ctx)with no signal and no bound, with the event stream still attached. #148 assumed pi's abort cascade means this can't hang. It can: a model request or tool that ignores the abort signal keeps pi's run alive, andrun()never returned (red check below).What
src/pi/engine.ts: after an abort,waitAfterAbortgives piPI_ABORT_GRACE_MS(30s) to settle. Then it stops waiting, thefinallydetaches the stream, it logspi: run did not settle after abort, andrun()returnsunansweredwith reasonabort_timeout. The grace wait has its own abort signal, so no orphaned wait is left behind.PiTurnInput.abortGraceMsoverrides the grace (tests).CodingAgent.piAbortGraceMsOverrideis the test hook.docs/session-watchdog.mdcovers the grace and the known gap. It also moves two Limitations bullets back under their heading (fix(prompts): fail a turn that stops making progress, not only inside a model request #148 put the guard section in the middle of the list).Known gap (not fixed here)
While the orphan is stuck, pi queues the session's next submission behind it. After the orphan ends, pi sometimes runs the queued prompt and sometimes leaves it
queuedwith no task. Then only the turn stall guard (15 min) ends it. Both outcomes showed up in the e2e. The same happens on the engine frommain, so this PR didn't cause it.close()+ reopen andharness.resume()did not free the queued submission. The e2e pins the part that is deterministic.Tests
test/pi-engine.test.ts: a tool that ignores the abort.run()returnsabort_timeoutwithin the grace and logs the warning. Red check: with the old unbounded wait, this test times out.test/pi-default-e2e.test.ts, in a real CodingAgent DO: a model request that ignores the abort (stuck model promptinpi-models-mock). The prompt endsaborted, andrun()returnsabort_timeout~300ms after the abort. A prompt sent meanwhile staysrunningand its model request isn't made. After release it either completes or fails withTurn stalled.npx vitest run: 116 files, 1379 tests pass.tsc --noEmitandbiome lintare clean.Adversarial review: 4 rounds (claude-haiku-5-5, plus gemini-3.5-flash on round 3; Gemini and its DeepSeek fallback timed out on rounds 1, 2 and 4 under Mac load). Round 4 ran because round 3 found two medium test issues. 10 findings fixed. Rejected: "an orphan can commit a late reply into the transcript". That is pre-existing, and
runPiChatalready returns early on an aborted signal. The round-4 lows were fixed without another review.beep-boop-🤖