feat: deliver completion mid-turn and bound finished processes - #6
Open
any-victor wants to merge 2 commits into
Open
feat: deliver completion mid-turn and bound finished processes#6any-victor wants to merge 2 commits into
any-victor wants to merge 2 commits into
Conversation
Lifecycle completion was the only wake still sent with deliverAs "followUp", which Pi delivers only once the agent has no pending tool calls. An agent that kept polling a process therefore never saw the completion until it went idle, and finished records piled up until someone asked for a clear. Completion now steers like output and stall wakes, the manager prunes the oldest finished records past retention.maxFinished (default 10, logs kept) after every process end, and the tool description, start result, and skill tell the model which alerts apply and not to poll.
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
Operator report (2026-09-02): completion notices only arrived once the agent went idle, agents kept polling
output/listanyway, and finished processes accumulated (22 in one session) until someone asked for aclear.What
src/hooks/process-end.ts: lifecycle completion now sendsdeliverAs: "steer"(likeprocess-watchandprocess-stall). Pi queues it while the current tool calls finish and delivers it before the next LLM call.followUpwaited until the agent had no pending tool calls at all — the opposite of push-not-poll. Tests:src/hooks/process-end.test.ts.src/manager.ts:pruneFinished(max)runs after everyprocess_ended, dropping the oldest non-live records beyondconfig.retention.maxFinished(default 10,0= unbounded). Log files are kept sostart/logspaths stay readable;clearFinished()still deletes them. Live processes are never pruned. Tests insrc/manager.test.ts.src/config.ts+/ps:settings: newretention.maxFinished.src/tools/index.ts,src/tools/actions/start.ts,skills/pi-processes/SKILL.md: the model is told which alerts apply on eachstartand not to poll.Verified
pnpm typecheck,pnpm lint,pnpm test(58 tests, 8 new; the provider-prefix stability test still passes with the new guideline text).