Repository navigation
fix(pi): settle OMP status from the agent_end contract - #17209
Conversation
Greptile SummaryThe PR changes OMP completion handling to use the
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains.
|
| Filename | Overview |
|---|---|
| src/main/pi/agent-status-handler-source.ts | Routes OMP terminal completion directly through the provider event contract while retaining the existing Pi and Prime idle-based path. |
| src/main/pi/agent-status-extension-omp-lifecycle.test.ts | Covers configured and runtime-routed OMP continuation and terminal sequences, plus Pi and Prime isolation. |
| src/main/pi/agent-status-extension-test-harness.ts | Extracts the generated-extension VM harness for reuse by lifecycle tests without changing production behavior. |
| src/main/pi/agent-status-extension-source.test.ts | Adopts the shared harness and narrows legacy idle-polling expectations to Pi and Prime. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[OMP agent_end] --> B{willContinue is true?}
B -->|Yes| C[Remain working]
B -->|No or absent| D[Post agent_end once]
D --> E[Pane status becomes done]
F[Pi or Prime agent_end] --> G[Existing settled or idle-check path]
Reviews (4): Last reviewed commit: "fix(pi): preserve non-terminal continuat..." | Re-trigger Greptile
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review. 📝 WalkthroughWalkthroughThe agent-status extension treats OMP Merge Risk: ⚪ Minimal · up to The change makes OMP turn status follow the agent's terminal completion contract while preserving existing Pi and Prime behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description is complete and relevant. It includes the ELI5 summary, changed behavior, rationale, linked issue, testing details, visual proof, review considerations, scope boundaries, and checklist context.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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 |
8d07b6a to
a1a7fae
Compare
OMP exposes no agent_settled hook and ctx.isIdle() can stay false after a finished turn, so Orca's idle-recheck loop backed off and spun forever and the pane stayed "working" indefinitely. OMP instead marks non-terminal agent_end events with willContinue; honor that for configured and runtime-routed OMP and treat an absent flag as terminal. Extracted from #15658, which bundles this with a launch-authority change that conflicts with in-flight #17077. Only the settle half lands here. STA-4130 Co-authored-by: Bing.Z <[email protected]>
a1a7fae to
f173226
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Refreshed this PR onto current |
Keep the base Pi and Prime willContinue guard while settling terminal OMP events directly. Add regression coverage so sibling runtimes cannot publish a false completion after conflict resolution.
Electron CDP visual validationValidated #17209 from child worktree Live OMP surface: a Settlement UI (seeded on the live OMP pane, matching the PR’s two outcomes):
Unverified: a real OMP model turn that emits Idle live OMPWorking (continuation analogue)Settled (terminal agent_end analogue) |
Final preparation status
|
* fix(pi): settle OMP status from the agent_end contract OMP exposes no agent_settled hook and ctx.isIdle() can stay false after a finished turn, so Orca's idle-recheck loop backed off and spun forever and the pane stayed "working" indefinitely. OMP instead marks non-terminal agent_end events with willContinue; honor that for configured and runtime-routed OMP and treat an absent flag as terminal. Extracted from stablyai#15658, which bundles this with a launch-authority change that conflicts with in-flight stablyai#17077. Only the settle half lands here. STA-4130 Co-authored-by: Bing.Z <[email protected]> * fix(pi): preserve non-terminal continuation guards Keep the base Pi and Prime willContinue guard while settling terminal OMP events directly. Add regression coverage so sibling runtimes cannot publish a false completion after conflict resolution. --------- Co-authored-by: Bing.Z <[email protected]> Co-authored-by: Merge Sim <sim@local>



ELI5
When an OMP agent finishes its turn, Orca's pane status could stop matching reality — most visibly, a finished turn that keeps showing as running.
Orca ends a terminal turn one of two ways: the agent fires an
agent_settledevent, or Orca pollsctx.isIdle()until it flips true. OMP has noagent_settledhook, so Orca falls back to polling — andisIdle()is a proxy for "the turn ended", not the thing itself.That proxy is what breaks, but how it breaks depends on the OMP build, so this PR does not lean on any one mechanism:
ctx.isIdle()staysfalseinside Orca's completion path, the recheck loop backs off and spins, and the workspace keeps showing "working" after OMP has returned to its prompt.ctx.isIdle()resolves to!session.isStreaming; the session clears that flag in itsagent_endarm, and it defers the extension-visibleagent_enduntil its in-flight counter drains — so by the time the extension's handler runs,isIdle()already readstrue. The proxy then reports idle during a scheduled automatic continuation, and the pane can go quiet while OMP is still working.Same root cause either way: Orca is inferring OMP's turn boundary instead of reading it.
OMP does tell you, though. Its
agent_endpayload carries awillContinuefield:truemeans "I've scheduled an automatic continuation", and anything else — including the absent/undefinedvalue a normal finished turn carries — means the turn is over. Orca was never reading it: a grep forwillContinueacrossmainreturns zero hits. This PR reads it.Before / after
Before: the pane's status could disagree with what the agent was actually doing, in either direction. An OMP agent finished its turn and the workspace kept showing "working" — the running indicator in the sidebar and on the tab never settling (#14278). On builds where the idle poll does flip, the reverse: the pane showed done part-way through, while OMP was still working through an automatic continuation.
After: the pane says what the agent says. A finished turn settles the running indicator right away, and a turn that announces "I'm going to keep going" keeps showing working until the agent actually stops.
What changed
Six lines in the generated Pi/OMP status extension's
agent_endhandler:isOmpRuntime()already exists onmainand already covers both the configuredompkind and a Pi-kind pane runtime-routed to OMP byprocess.title/process.argv. The handler's_eventparameter is renamed toeventso the payload is readable.What each agent version does
agent_settledeventagentSettledSupportedshort-circuits before any recheck.ctx.isIdle()flips true after the finalagent_endctx.isIdle()isOmpRuntime()is hardcodedfalsefor theprime-agentkind.agent_endcarryingwillContinue: trueagent_endarrives.agent_endwithwillContinueabsentThe absent flag is the common path, not an edge case. Measured against the shipped OMP binary
(
omp/17.0.5): the extension-facing emit isemit({ type: 'agent_end', messages, willContinue: j?.willContinue }), and its caller has 18 routes —10 pass
{ willContinue: true }, 4 pass nothing, and 4 passcond ? { willContinue: true } : undefined.So a terminal OMP turn always arrives as
willContinue: undefined, andwillContinue: falseis neveremitted on this event at all. OMP's own in-tree consumer of the same event agrees: it reads
if (w.willContinue) return, i.e. absent means terminal there too.=== trueis therefore reading theprimary shape, not defending against an unusual one.
Design constraints
event?.willContinue === true. An absent flag, an absent payload, andwillContinue: falseall settle the turn — and since current OMP emits the flag only on a continuation, "absent" is what a normal finished turn looks like. A build that cannot send the field is never asked to.agent_endhook event is posted, not its shape. The hook payload, the RPC surface, and the stream opcodes are untouched, so a mixed client/host pair is unaffected. SSH panes get the same generated extension text they already get.Extracted from #15658
#15658 bundles this settle with a launch-authority change (OSC
133;Dno longer retiring launched-agent hook authority until the execution host confirms a foreground shell). That half touchesorca-runtime.ts,daemon/,agent-hooks/server.ts,ssh-pty-provider.tsandshell-process-detection.ts, and is where all five of #15658's conflicts againstmainlive — colliding with in-flight #17077. The settle half auto-merges clean.Taken here (4 files):
src/main/pi/agent-status-handler-source.ts— thewillContinuebranch and its comment.src/main/pi/agent-status-extension-omp-lifecycle.test.ts— new spec (configured / title-routed / argv-routed OMP, continuation, continuation-then-terminal, Pi/Prime isolation).src/main/pi/agent-status-extension-test-harness.ts— the extension VM harness, lifted out ofagent-status-extension-source.test.tsso both specs share one copy.src/main/pi/agent-status-extension-source.test.ts— imports the shared harness;keeps reporting Pi-compatible agents once their agent_end handlers settleis renamed tokeeps polling Pi and Prime until their agent_end handlers settleand drops'omp'from its kind loop. That case asserted the old OMP contract and the new spec now owns OMP.Left in #15658 (22 files) — the whole launch-authority half:
agent-hooks/server.ts(+ 2 specs),daemon/(protocol version, pty adapter, session, types, + 4 specs),main/index.ts,ipc/pty-runtime-kill-and-exit.test.ts,providers/ssh-pty-provider.ts(+ spec),runtime/command-finished-launch-authority.ts(+ spec),runtime/orca-runtime.ts(+ spec),shared/agent-hook-listener-pi-compatible.test.ts,shared/shell-process-detection.ts(+ spec).One deliberate deviation. #15658's OMP branch opens with
clearPendingAgentEndCheck(). That line is unreachable: both sites that armpendingAgentEndChecksit below theisOmpRuntime()fence in the same handler, andisOmpRuntime()memoizes intocachedOmpRuntimeon first call so it cannot flip mid-process. Deleting it alone reddens 0 of 40 tests. Rather than ship a line that cannot be pinned, it is dropped and the reason recorded in the comment above the recheck constants. If the launch-authority half later needs it, it can come back with a test.The four symptoms tracked under STA-4130 share a class (Orca models OMP as a variant of Pi) but not a cause — they are four independent predicates with no call edge, and three fire mid-turn while the status is correctly "working". This settle is not upstream of them; it fixes the stuck-at-working one only.
Testing
Failing-first, 1-to-1, driving the real
agent_endpayload shape.agent-status-extension-omp-lifecycle.test.tsThe 8th case (
does not apply the OMP contract to Pi or Prime) is the isolation control and is green on both sides by design.Ablations — each mutation applied alone, verified by checksum before/after, tree restored and re-checksummed between runs, both spec files run each time (40 tests):
isOmpRuntime()block deleted (the rule itself)isOmpRuntime()→true(OMP-only fence removed)if (event?.willContinue === true) returndeleted=== true→!== false(require a positive terminal signal)clearPendingAgentEndCheck()deletedGates, each log read rather than trusted from a summary line:
tsc --noEmiton all three projects (tsconfig.node,tsconfig.tc.cli,tsconfig.tc.web) — exit 0, zeroerror TSin each log.oxlint --deny-warningson the four changed files — 0 warnings, 0 errors, 167 rules, 4 files.oxlint --deny-warnings --type-aware --config config/oxlint-code-quality-type-aware.json— 0/0, 5 rules, 4 files.oxlint --deny-warnings --config config/oxlint-react-doctor.json— 0/0, 12 rules, 4 files.check:max-lines-ratchet— OK, no new bypasses. Nomax-linesdisable or per-file bump added.git diff --check— clean.npx oxfmt --writeon the four changed paths only.src/main/pi,ssh-relay-session,agent-hook-listener-pi-compatible) — 117/117 passed.pnpm lint/ fullpnpm test/pnpm buildleft to CI.Visual Proof
Not N/A. Agent status
donedrives more than the running indicator — it also gates desktopcompletion notifications, smart attention, and paired-web sync. An Electron/CDP lane measured
three of those four surfaces at this PR's head. The two it could not reach are named as blocked
below rather than claimed.
Measured — behaviour across a real automatic continuation, the case this change exists for:
workingfor the full 20.15s continuation — never flickers to done between turnsThe continuation is the discriminating case: settling from an idle recheck rather than from the
agent_endcontract is what would drop the indicator and fire an early completion notificationmid-turn.
Blocked — not measured, and not claimed:
transition was never observed.
The notification row above records that the notification was dispatched at +1.8s — not that
the operating system rendered it.
Review
willContinueis a strict=== trueread on an in-process extension event.omp.exe/omp.cmd/omp.bat.willContinuefail open to done. Pi and Prime are untouched.Linked Issue
Covers the stuck-at-working completion path of STA-4130 / #14278.
Author