Repository navigation
Leave no Pi extension timer armed after session_shutdown, and register the prompt handler previewSafe - #662
Merged
Conversation
…rompt handler previewSafe omo closes every timer an extension still holds after session_shutdown and warns about it, and it skips previews of the next system prompt while a before_agent_start handler is not registered previewSafe, which made omo --print-prompt-sizes exit 1.
terminateGroup clears its grace timer when the caller's exit settles and the process is no longer ours, and with no exit to wait on, as for a restored orphan, when a 50 ms poll finds the leader gone. hc and Orca pass their run's exit; T3's end() clears its grace timer and stops a waiting steer when the run ends. The timer recorder moves to tests/pi/timer-recorder.mjs so the Orca and T3 tests can use it.
…settles terminateGroup now checks the leader every 50 ms in every case, so a process still exiting when its run's exit settles, as on the herdr-core error path, no longer keeps the grace timer for the full grace. The SIGKILL test waits for sh to set its trap instead of sleeping 100 ms.
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.
On omo 5.1.92, the Pi extension left a timer armed after
session_shutdown, and omo warned on stderr that it had closed it.omo --print-prompt-sizesexited 1 because thebefore_agent_starthandler was not registered previewSafe, which also makes omo skip its prompt-cache prewarm.What changed
child.ts,PiChildclears its 30 s close timer when the child exits on its own.terminateGroupends its grace early once the group's leader is gone. A 50 ms check of the leader covers every caller, including a restored orphan whose exit nothing reports. A caller whose run has an exit promise also passes it, which ends the grace at once ifours()no longer holds then. If the leader is still ours when the grace runs out, SIGKILL goes out as before.hc-child.tsandorca-child.tspass the run'sexitedtoterminateGroup.t3-child.ts,end()clears its grace timer when the run ends, and a steer still waiting on that run stops waiting then.one-shot.ts, the 50 ms pending-message poll a print run keeps during its settle hold stops when the hold ends, in afinally, so a rejected wait for an agent stops it too.prompt.ts, the handler is registered with{ previewSafe: true }. It reads the models sheet and the mandate, asks git for the project root, and returns what the turn gets. Pi 1.5.1 and 1.8.0 typeon()with two arguments, so the call goes through a widened function type; Pi ignores the third argument at runtime.Tests
tests/pi/timer-recorder.mjscounts timers the way omo'sExtensionHandleLedgerdoes. A timer armed by code underplugins/pstack/picounts until it fires or is cleared. Each test below failed on the code before its fix and passes now:shutdown-timers.test.mjs: a foreground agent, a stopped agent, a print run's settle, a settle whose wait for an agent rejects, and a reaped orphan, checked 1 s into a 5 s grace.orca-child.test.mjs,t3-child.test.mjs: a stopped run leaves no timer once it has exited.child.test.mjs: a group still ours when its run's exit settles gets SIGKILL after the grace, and a leader still alive then ends the grace once it is gone.prompt.test.mjs: a preview gets the same sections as the turn.Checks
omo 5.1.92, engine senpi 2026.12.1-6, ran in a
node:24container with a stub model and no credentials. Main's Pi code has not changed since 7c6620d.-p, 20 runsstop_agent--print-prompt-sizesextension:pstack1440 bytesbun test tests/at 53917f1: 2950 pass, 0 fail, 300 skip.bun tools/typecheck-pi.mjs: exit 0 against Pi 1.5.1 and 1.8.0.PSTACK_PI_LIVE=1 bun test tests/pi/live.test.mjson Pi 1.5.1 at 53917f1: 11 pass, 0 fail, 58 model calls.Four reviews: one covered
da4ae3e9, one coveredc4083e17and9734b297, and one covered12bb8411and53917f18. None found anything high or medium.53917f18handles two findings of the second review: a leader still exiting when its run's exit settled kept the full grace, and the SIGKILL test slept a fixed 100 ms waiting for a trap.c3aca9fehandles two of the third: the new leader-exit test's limit goes from 1 s to 2 s, and the changelog now says nothing observable changes on Pi. A fourth review coveredc3aca9fealone and found nothing to change in the code or tests.c3aca9fechanges only that test limit and one changelog sentence, so the results above at 53917f1 hold for it.child.test.mjspassed 3 of 3 runs at it.Rough edges
PSTACK_PI_HC_LIVEset. Its change is one line, and only theterminateGrouptests cover it.terminateGrouptest covers Orca's SIGKILL path.pichild process paths only. The hc, Orca, T3 and reap paths were not run on omo.