Repository navigation
fix(pi): suppress subagent agent_end so nested sessions don't fire false notifications - #8545
Conversation
…lse notifications Pi/OMP run subagents as nested child processes that inherit the lead pane's env (including ORCA_PANE_KEY), each loading its own copy of the orca-agent-status.ts extension. A child's agent_end was attributed to the lead pane, firing a false "agent finished" notification on every subagent completion. Gate status reporting to the top-level Pi process per pane via an ORCA_PI_STATUS_OWNED env marker: the first process claims the pane and sets the marker; any Pi it spawns inherits it and stays silent. Keyed on process nesting (not hasUI) so a top-level non-interactive `pi -p` run still reports its own completion.
aef8508 to
8d9b5ef
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPi status handlers now suppress lifecycle, tool, and assistant message reporting from nested subagents using the 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/main/pi/agent-status-extension-source.test.ts (1)
186-199: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winTests pass but coverage is narrow.
The two new tests verify
agent_endsuppression and top-level delivery, which is the core of this PR. However, themessage_endhandler now adds assistant-role filtering (line 84 in the handler source) and all other events (before_agent_start,tool_execution_start,tool_call,tool_execution_end) share the samereportsToPane()guard — none of these are directly tested for nested suppression. Consider adding a test that fires a non-assistantmessage_endor atool_callin a nested harness to confirm silence, which would protect against regressions if the guard is ever refactored per-event.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6e919e67-2213-4e16-976d-dfe0213d3097
📒 Files selected for processing (2)
src/main/pi/agent-status-extension-source.test.tssrc/main/pi/agent-status-handler-source.ts
|
Tip For best results, initiate chat on the files or code changes.
ᕦ(ò_óˇ)ᕤ |
|
reviewing |
…the lead The subagent-suppression gate marked the pane owner with a boolean ORCA_PI_STATUS_OWNED='1'. Pi re-invokes an extension's default export on every in-process reload (/reload, live edit, settings reload), so the lead process re-ran the factory, read the '1' it had set on first load, and treated itself as a nested subagent — silencing all its own status (working, tools, done, notifications) for the rest of the session. Record the owning process's pid instead. A same-process reload matches its own pid and keeps reporting; a spawned subagent inherits the lead's pid, sees it differs from its own, and stays silent. Startup was unaffected (bindExtensions runs the factory once), which is why the single-run trace missed it. Add a reload regression test that re-invokes the factory in the same process and asserts the lead still reports; it fails against the boolean marker. Co-authored-by: Orca <[email protected]>
|
Pushed a follow-up commit ( The bug: the boolean marker silences the lead on extension reloadPi re-invokes an extension's default export every time extensions (re)load in the same process — Because the gate marks the pane owner with a boolean
A boolean can't distinguish "a child process inherited my env" from "I re-ran in the same process." Startup only invokes the factory once ( The fix: key the owner on pid, not a booleanconst ownerPid = process.env.ORCA_PI_STATUS_OWNED
const selfPid = String(process.pid)
const isNestedAgent = !!ownerPid && ownerPid !== selfPid
if (!ownerPid) process.env.ORCA_PI_STATUS_OWNED = selfPidA same-process reload matches its own pid → keeps reporting. A spawned subagent inherits the lead's pid, sees it differs → stays silent. Set-only-when-unset keeps the original lead pid stable down the subagent tree. Added a reload regression test that re-invokes the factory twice in one process and asserts the lead still reports — it fails against the old boolean marker. What I verified in pi's source (the approach itself is sound)
Verificationoxlint clean · all 3 typecheck configs (node/cli/web) exit 0 · 273 tests pass across Out of scope (not a bug): pi subagents still don't surface as |
|
Completed a deep review of the latest branch and pushed One additional issue surfaced: nested processes still registered every status handler and depended on each handler carrying its own guard. That made the fix fragile—any future hook added without the guard could reintroduce false lead-pane notifications. The follow-up moves the ownership check to the extension factory boundary, so nested Pi/OMP processes register zero status hooks. The PID owner marker still preserves same-process Coverage now explicitly exercises Pi and OMP descendants, a grandchild process, non-interactive top-level Validation on
The fork workflow was created and I approved its Actions run so PR CI can execute: https://github.com/stablyai/orca/actions/runs/29463984466. |
AmethystLiang
left a comment
There was a problem hiding this comment.
Reviewed the latest head (1a574e43f) after the factory-level ownership hardening and full local validation. I found no remaining correctness, cross-platform, SSH, transport, or test-coverage blockers. Approved.
|
The PR's documented in-process limitation is now reproducible with OMP 17.0.2: task workers are child AgentSession instances in the same PID, and the hidden 'yield' completion can trigger a false top-level notification. This is tracked with reproduction details in #9181. The PID ownership gate appears to need session-level origin for current OMP. |
…lse notifications (stablyai#8545) * fix(pi): suppress subagent agent_end so nested sessions don't fire false notifications Pi/OMP run subagents as nested child processes that inherit the lead pane's env (including ORCA_PANE_KEY), each loading its own copy of the orca-agent-status.ts extension. A child's agent_end was attributed to the lead pane, firing a false "agent finished" notification on every subagent completion. Gate status reporting to the top-level Pi process per pane via an ORCA_PI_STATUS_OWNED env marker: the first process claims the pane and sets the marker; any Pi it spawns inherits it and stays silent. Keyed on process nesting (not hasUI) so a top-level non-interactive `pi -p` run still reports its own completion. * test(pi): assert nested-subagent silence for every guarded event, not just agent_end * fix(pi): key status owner on pid so extension reload doesn't silence the lead The subagent-suppression gate marked the pane owner with a boolean ORCA_PI_STATUS_OWNED='1'. Pi re-invokes an extension's default export on every in-process reload (/reload, live edit, settings reload), so the lead process re-ran the factory, read the '1' it had set on first load, and treated itself as a nested subagent — silencing all its own status (working, tools, done, notifications) for the rest of the session. Record the owning process's pid instead. A same-process reload matches its own pid and keeps reporting; a spawned subagent inherits the lead's pid, sees it differs from its own, and stays silent. Startup was unaffected (bindExtensions runs the factory once), which is why the single-run trace missed it. Add a reload regression test that re-invokes the factory in the same process and asserts the lead still reports; it fails against the boolean marker. Co-authored-by: Orca <[email protected]> * fix(pi): gate nested status hooks at registration --------- Co-authored-by: Jinjing <[email protected]> Co-authored-by: Orca <[email protected]>
…the PID alone (#480) An inherited ORCA_PI_STATUS_OWNED naming a live PID muted the whole descendant tree, so a session that inherited the marker but reports for another pane sent nothing at all — no session_start, no turn events, no scheduled_work — while Orca showed the pane idle. Env only reaches descendants, so the bare PID could not separate the pane's own nested subagent (which must stay silent, stablyai#8545) from a different pane's reporter. A claim now records the claimant's ORCA_PANE_KEY beside its PID, and an inherited marker recorded for another pane is no claim on this one; a claim with no pane record of its own deletes the stale one, so a new owner never pairs with an old pane. Both lanes use the shared predicate, so the status and titlebar lanes cannot drift (#229). The three _PANE companion keys are stripped at every pane boundary beside the keys they belong to. The stand-down is no longer silent: it is recorded on globalThis keyed by lane, and warned once per process when stderr is a TTY or ORCA_PI_STATUS_DEBUG is set. A piped subagent nobody asked to debug stays quiet.
…the PID alone (#480) (#500) An inherited ORCA_PI_STATUS_OWNED naming a live PID muted the whole descendant tree, so a session that inherited the marker but reports for another pane sent nothing at all — no session_start, no turn events, no scheduled_work — while Orca showed the pane idle. Env only reaches descendants, so the bare PID could not separate the pane's own nested subagent (which must stay silent, stablyai#8545) from a different pane's reporter. A claim now records the claimant's ORCA_PANE_KEY beside its PID, and an inherited marker recorded for another pane is no claim on this one; a claim with no pane record of its own deletes the stale one, so a new owner never pairs with an old pane. Both lanes use the shared predicate, so the status and titlebar lanes cannot drift (#229). The three _PANE companion keys are stripped at every pane boundary beside the keys they belong to. The stand-down is no longer silent: it is recorded on globalThis keyed by lane, and warned once per process when stderr is a TTY or ORCA_PI_STATUS_DEBUG is set. A piped subagent nobody asked to debug stays quiet. Co-authored-by: Nathan Plesnicher <[email protected]>
Summary
Pi/OMP run subagents as nested child processes that inherit the lead pane's env (including
ORCA_PANE_KEY), each loading its own copy of theorca-agent-status.tsextension. A child'sagent_endwas attributed to the lead pane, firing a false "agent finished" notification on every subagent completion. This gates status reporting to the top-level Pi process per pane, keyed on process nesting so top-level runs — interactive and non-interactivepi -p— still notify, while nested subagents stay silent.Changes
agent-status-handler-source.ts) — the first Pi process to load the extension readsORCA_PI_STATUS_OWNED, finds it unset, reports normally, and sets it. Any Pi it spawns inherits the marker and suppresses all its lifecycle posts. Chosen over ahasUI/modecheck specifically so a top-level non-interactivepi -prun (which ishasUI=false) still reports its own completion.getPiAgentStatusExtensionSource), so it applies to both agents and to local + SSH/remote panes with no duplication.Testing
pnpm test— 29,114 passed, 42 skipped, 0 failed (full suite). Scopedagent-status-extension-source.test.ts: 14 passed (11 existing + 3 new).pnpm typecheck— clean (node, cli, web tc configs).oxlintclean on changed files.pnpm build— exit 0 (desktop + native).ORCA_PI_STATUS_OWNED=1) posts nothing; a top-level run (interactive or non-interactive) postsagent_endand claims the env marker.ppid= lead pid) in headless mode, sharing the lead's pane key, each firingagent_end; the lead never firedagent_endwhile still working.Screenshots
No visual change — this affects OS-notification timing only.
Security Audit
No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes. The diff reads and sets one internal process env marker (
ORCA_PI_STATUS_OWNED) and branches on it; no new external input is trusted and no new surface is introduced.AI code-review summary
Notes
agent_ends; this handles subagent-origin ones). Referenced for context only.agent-hook-listener.ts(defense-in-depth only); the extension gate is the root fix since that's where the lead-vs-child origin info exists.