Skip to content

feat: deliver completion mid-turn and bound finished processes - #6

Open
any-victor wants to merge 2 commits into
mainfrom
fix/completion-steer-retention
Open

feat: deliver completion mid-turn and bound finished processes#6
any-victor wants to merge 2 commits into
mainfrom
fix/completion-steer-retention

Conversation

@any-victor

@any-victor any-victor commented Sep 2, 2026

Copy link
Copy Markdown

Why

Operator report (2026-09-02): completion notices only arrived once the agent went idle, agents kept polling output/list anyway, and finished processes accumulated (22 in one session) until someone asked for a clear.

What

  • src/hooks/process-end.ts: lifecycle completion now sends deliverAs: "steer" (like process-watch and process-stall). Pi queues it while the current tool calls finish and delivers it before the next LLM call. followUp waited 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 every process_ended, dropping the oldest non-live records beyond config.retention.maxFinished (default 10, 0 = unbounded). Log files are kept so start/logs paths stay readable; clearFinished() still deletes them. Live processes are never pruned. Tests in src/manager.test.ts.
  • src/config.ts + /ps:settings: new retention.maxFinished.
  • src/tools/index.ts, src/tools/actions/start.ts, skills/pi-processes/SKILL.md: the model is told which alerts apply on each start and not to poll.
  • AGENTS.md / EVENTS.md / README updated; patch changeset.

Verified

pnpm typecheck, pnpm lint, pnpm test (58 tests, 8 new; the provider-prefix stability test still passes with the new guideline text).

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant