In-session continuation behind token, idle, and bounds gates, accept DL-008 (+DL-013, DL-014) - #38
Closed
jimutt wants to merge 3 commits into
Closed
In-session continuation behind token, idle, and bounds gates, accept DL-008 (+DL-013, DL-014)#38jimutt wants to merge 3 commits into
jimutt wants to merge 3 commits into
Conversation
…ept DL-008 agent_end advances an active run when it is safe: token checked at entry and again after the awaited script calls, idle and no pending messages, on-disk status active, wall-clock bounds within limits, and next-item selecting work. Empty next-item output means the run is complete, not an error - the failure mode the first draft got wrong, spamming an error on every turn after the last item. turn_end finishes the completion transaction. With review enabled the loop cannot accept - it notifies once that the review subagent must run and the item stays verifying. With review disabled it accepts with every write checked, aborting on the first failure so state and the event log never contradict. Failures retry once, then block with the reason (DL-004). Event handlers catch every error and notify rather than throw, because an exception in an extension handler repeats on every turn for the rest of the session. The empty start bug the user hit live - a run with no items treated as an error forever - is the same class, fixed the same way. The token gate is honest about what it guards: the in-flight race between script calls and dispatch, not a queued continuation that does not exist. The primary anti-stale guard is the on-disk status check. Co-Authored-By: Claude Opus 5 <noreply@pi.dev> Generated-By: pi 0.84.2
Three facts from live testing reshaped the wiring: - isIdle() is false at agent_end in every mode (the flag clears only at agent_settled), so an idle gate at event time can never pass - pi invalidates the extension runtime at session disposal and reload, so a handler still awaiting script calls dies with a stale-ctx error - pi-goal-pro's production pattern is a setTimeout that returns from the handler immediately and re-checks gates in the deferred callback The handler now schedules, the deferred callback dispatches via pi.sendMessage with triggerTurn, and user input suspends continuation until /dld-goal resume. Resume and start dispatch immediately so the loop never waits for a turn that may not come. DL-013 amends DL-008: the record's agent_end rationale was right about the event, wrong about gating on idle at event time and about awaiting in the handler. Verified end-to-end in RPC mode (resume dispatches a second agent start). Co-Authored-By: Claude Opus 5 <noreply@pi.dev> Generated-By: pi 0.84.2
Co-Authored-By: Claude Opus 5 <noreply@pi.dev> Generated-By: pi 0.84.2
Owner
Author
|
Superseded by feat/pi-harness-extension — all commits from this branch are merged there. See #41 for the findings log on top. |
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.
What
In-session continuation: agent_end advances an active run when it is safe. The handler schedules a deferred dispatch (never awaits script calls inside the handler, because pi invalidates the extension runtime at session disposal), and the deferred callback re-checks gates and dispatches via pi.sendMessage with triggerTurn.
User input suspends continuation; /dld-goal resume and start clear suspension and dispatch immediately. Esc suspends the loop on abort detection (DL-014). Pause aborts the current turn via ctx.abort().
turn_end finishes the completion transaction. With review enabled the loop cannot accept; with review disabled it accepts with every write checked, aborting on the first failure.
Three facts from live testing reshaped the wiring, recorded as DL-013 and DL-014 amending DL-008.
Stacks on #37.