Repository navigation
Keep a Pi chat awake while its background subagents run - #38207
Conversation
The idle sweep stopped a Pi chat 30 quiet minutes after its last turn even while pi-subagents workers it had started in the background were still running. On Windows those workers are children of Pi and died with it, so the coordinator never got their results. Pi extensions with detached work already declare it through the shared session-liveness registry that Pi hosts read before idle eviction, and pi-subagents registers there. Native chat runs Pi as a child process, so Orca now loads a small bridge extension into native-chat Pi launches that installs that registry at load and reports, over Pi's RPC stdout, whether the session has active providers. The Pi adapter keeps the last report and the idle sweep treats it like provider-held sends: the chat is not stopped while work is declared, and idles a full window after it ends. Nothing else reads it, so clear and compaction are unchanged. Tracked in #28710.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
Keep the bridge ticking after a failed report so the next answer is re-derived, validate registrations the same way the reference host does, log a bridge that could not be written, and use type guards in its test.
A cached report could be stale when work starts between samples, so the idle sweep now asks a running child's provider right before stopping it and stops only on a fresh idle answer. Pi's bridge answers requests that Orca drops into a private per-child folder, replying on its status line, so the probe never becomes a dialog or a prompt other extensions or the model would see. A child launched without the bridge stops as before; one with the bridge but no ready instance is left for the next sweep.
Recorded on Windows from Pi 1.5.0 with pi-subagents 0.84.0 and the bridge: ready, active while a worker ran, idle after its wake turn, and shutdown.
…nswers A launch abandoned before Pi started left its prepared folder behind, so the bridge now creates the folder itself. An answer with no probe pending could throw while reading Pi's output; replies are now matched exactly and anything else times out as unknown. Leftover folders are reclaimed only when their Orca process is proven gone.
The idle stop now re-reads the chat idle setting after the provider's answer, so switching a chat to Never during the probe keeps its agent. Normalize each Pi launch's private probe folder in the launch parity snapshots, which now include the background-work bridge.
|
Review status: done on What broke: a Pi native chat waiting on a pi-subagents background worker looked idle to Orca. After 30 quiet minutes the idle sweep stopped Pi, killing the worker (Windows) or losing its wake-up turn, so the result never came back. What changes: before stopping a quiet Pi chat, Orca asks Pi, through a small bridge extension and a private per-chat folder, whether a registered provider (pi-subagents) still owns work. Only a fresh "idle" answer from the current bridge lets the sweep stop the chat; "active" keeps it running and silence or a malformed reply skips that tick. Once the work ends the chat still idle-stops a full window later. Other agents are unchanged. Review: independent Claude Opus-medium and Codex-high reviewers, 9 rounds, both ready at QA (real app runs):
Noticed, not part of this PR: picking Pi in the New tab menu opens a Pi terminal, not a native chat (the chat is reached via Configure Pi → Launch chat). |




Tracked in #28710 (the background-subagent report; the idle-window setting in that issue is separate).
Problem
A Pi coordinator in a native chat can start a
pi-subagentsworker in the background and end its turn. Orca's idle sweep then stopped that chat 30 quiet minutes later, even though the worker was still running. On Windows the workers are child processes of Pi, so they died with it: the run stayed "running" on disk, no result came back, and nothing woke the coordinator. The same flow in a terminal tab finished a 45-minute worker. The reporter saw 9 of 11 long workers die 29–33 minutes after the coordinator's last turn.Why: the sweep stops an idle agent unless it still owes work, and nothing told it about Pi's background work.
What changes for users
A Pi chat with background subagents still running is no longer stopped. Once the work and its wake-up turn are done, it stops after the usual 30 quiet minutes. Nothing new appears on screen, and clear, compaction and Stop behave as before.
How it works
pi-subagentsregisters there on every session start and releases on shutdown or reload. It counts queued and running background runs, nested children, undelivered results and the pending wake turn.--extension). The bridge installs the registry when it loads. Each bridge instance announces itself with a fresh id on its status line and watches a private folder Orca made for that child.Differences from the common pattern
Not covered
pi-subagents, or a version without the registry: still idle-stops after 30 quiet minutes, as before (nothing registers as busy).Review path
Full path: the lifecycle of a native-chat agent process (idle stop). Plan reviewed by the independent Claude and Codex reviewers. Two design questions went to the independent decider:
Tests