Skip to content

fix(agent-status): keep a Devin run under Pi from pinning the pane on Needs input - #22800

Closed
mmarabel wants to merge 3 commits into
stablyai:mainfrom
mmarabel:mmarabel/fix-devin-hook-under-pi
Closed

mmarabel wants to merge 3 commits into
stablyai:mainfrom
mmarabel:mmarabel/fix-devin-hook-under-pi

Conversation

@mmarabel

@mmarabel mmarabel commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Pi can run Devin as a model through the pi-devin-acp extension. When Devin needs permission to run a command, Pi shows its own dialog, and Orca already reports that dialog as "Needs input". But Devin's own Orca hook also fired, marking Pi's pane "Needs input" a second time. Pi reports nothing while Devin works on the approved command, so the pane stayed on "Needs input" after the user had already approved. With this change Devin's hook stays quiet while Pi is reporting the pane, and the status follows Pi.

What Changed

Before: in a Pi pane using a Devin model, approving a Devin permission request left the sidebar on "Needs input" until Devin finished its whole turn.

After: the sidebar shows "Needs input" while Pi's permission dialog is open, "Working" once it is approved, and "Done" at the end. Standalone Devin panes behave exactly as before.

Mechanism:

  • pi-devin-acp starts devin acp with Pi's full environment, including the pane key. So Devin's managed hook (~/.orca/agent-hooks/devin-hook.sh / .cmd) posted /hook/devin events onto Pi's pane.
  • The server's nested-agent rule keeps the parent's identity and only drops a nested "done". So a nested PermissionRequest overwrote Pi's row with "waiting", and nothing from Pi corrected it while Devin worked.
  • Orca's Pi status extension already exports its PID to every descendant as ORCA_PI_STATUS_OWNED (Prime uses ORCA_PRIME_AGENT_STATUS_OWNED). The generated Devin hook now skips its post while that owner is alive:
    • macOS/Linux: a numeric check plus kill -0 <pid>. It sits after the payload is read from stdin, so Devin never sees a broken pipe. A PID left behind by an exited Pi does not silence anything.
    • Windows: cmd has no builtin way to check whether a process is alive. So the hook posts as before, adding the owner PIDs as two form fields. The shared hook listener (hasLivePiStatusOwner) drops a Devin event only while that PID is running, using the same rules as the POSIX guard. Hook and listener are on the same machine: the Windows script is only installed for local targets.
  • The owner keys (PI_STATUS_OWNER_ENV_KEYS) now live in src/shared/pi-status-owner-env.ts. The hook builders (src/main/agent-hooks/pi-status-owner-hook-guard.ts), the listener and the existing PI_PROCESS_OWNER_ENV_KEYS strip list all read that one list.
  • The new hook test runs the real cmd.exe script on Windows, so it is registered in the Windows CI lane: both the package_windows vitest list in pr.yml and WINDOWS_PACKAGE_TESTS. win32-test-lane-registration.test.mjs requires both. The guard module is also added to config/tsconfig.cli.json, which lists main-process files one by one.

Why

  • Pi already reports the real prompt. pi-devin-acp routes Devin's permission request through Pi's ctx.ui.select, which Orca's Pi extension maps to "waiting" and back to "working". Devin's hook only duplicated that, too late to clear.
  • Alternative: a server-side rule dropping nested "waiting". Rejected. The server cannot tell whether the parent reports the prompt itself, and the rule would hide real prompts from other nested agents. The hook can see the owner in its environment.
  • Alternative: skip the post in the Windows script whenever the owner variable is set. This was the first version of this PR. A process that outlived Pi kept the value, so its Devin events stayed hidden. Running tasklist on every event would fix that from cmd, but it adds time and EDR signal to every hook, so the listener checks instead.
  • Alternative: strip the pane key from Pi's children. Rejected. Orca does not control how a Pi extension spawns its children, and stripping it for all descendants would change unrelated shells.
  • Alternative: a marker that pi-devin-acp sets only on its devin acp spawn. This would narrow the skip to exactly the ACP case. It needs a release of a third-party package, and until then there would be no fix. It is a reasonable follow-up (see Notes).

Linked Issue

Fixes #22011

Visual Proof

N/A for a recording: this changes which status the sidebar shows, and I have no before/after capture. Verified end to end with real binaries instead (see Testing). To reproduce: in a Pi pane, run /model devin/swe-2 with Devin's yolo mode off and ask for a shell command. Approve Pi's permission dialog and watch the sidebar status.

Testing

  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

  • Live run (Linux): real pi -p --model devin/swe-2 with pi-devin-acp 0.5.0 and Devin 3000.11.1, with Devin's hooks pointed at old and new generated scripts and a local listener.

    • Old script: /hook/devin SessionStart, UserPromptSubmit, PreToolUse, PermissionRequest, PostToolUse, Stop and SessionEnd all posted on Pi's pane.
    • New script: only Pi's own /hook/pi events. The approved command still ran.
  • hook-script-pi-status-owner.test.ts runs the generated script against a real HTTP listener:

    • It posts with no owner, an exited owner, or a malformed owner (0, 00, -1, non-numeric, empty).
    • It drains a 256 KB payload without posting while either owner is alive.
    • The offline spool is skipped under a live owner and written without one.
    • On Windows (CI lane), the real cmd.exe script posts the owner fields, and each post goes through the real listener. It is dropped while the owner is alive and accepted after the owner exits or when no owner is set.
  • agent-hook-listener-pi-status-owner.test.ts: the listener drops Devin events while either owner is alive. It keeps them when the owner has exited or no owner is named. It never checks a malformed value (0, 00, -1, 1, non-numeric), and it leaves other agents' events alone.

  • Mutation checks: each test fails when its target breaks:

    • removing the POSIX guard or moving it after the post
    • using the plain 0 pattern (caught by the 00 case)
    • removing the listener drop or the Windows form fields
    • loosening the PID check
  • Local runs, all passing:

    • pnpm tc
    • vitest on src/shared/agent-hook-listener*, src/main/devin, src/main/pi, src/main/agent-hooks, src/relay, the child-process import boundary, pr-code-change-scope.test.mjs and win32-test-lane-registration.test.mjs. The two WSL hook relay tests fail identically on main on this host.
    • oxlint and oxfmt --check on the changed files
    • pnpm run check:code-quality:changed against upstream/main
  • Linux live and automated. Windows is covered by the CI lane only. macOS has not been run yet.

AI Disclosure

AI-assisted implementation and review.

Review

  • Platforms: POSIX uses case and kill -0, both built into sh on macOS and Linux. On Windows the hook keeps its single curl.exe post, and the listener checks liveness with Node's process.kill(pid, 0). No tasklist or PowerShell probe was added, so hook latency and EDR signal are unchanged.
  • Local/SSH/remote: the same POSIX guard ships through installRemote. kill -0 runs on the execution host, where Pi and Devin both live. Only the local Windows script sends owner fields, so the listener never checks a PID from another machine. Older scripts send no owner fields and keep today's behavior.
  • Folder workspaces: nothing here assumes a git worktree.
  • Agents/integrations: only the Devin hook changes, and only while a Pi-family status owner is alive. Standalone Devin panes are unaffected.
  • Performance: one shell builtin per Devin hook event on POSIX, and one process.kill(pid, 0) in the listener for Windows Devin events that name an owner.
  • Security: no new network access. The owner fields arrive on the existing authenticated hook post. The listener only checks a strictly numeric PID with signal 0, which checks existence without affecting the process.

Agent skill upstream boundary

  • Not applicable; no skill-installer source, fixtures, registries, or guides changed.

Notes

  • Trade-off: the skip applies to any Devin running under a live Pi status owner, not only devin acp. Devin gives its hooks no marker for ACP mode, only the parent process name.
    • Where Pi does not show Devin's prompt itself, that prompt no longer marks the pane "Needs input". Examples: Devin run interactively inside a Pi terminal overlay, or under an OMP/Prime owner or a nested Pi that is not the status owner.
    • Devin started from Pi's bash tool is not affected. Without a terminal, devin -p rejects the tool call itself, so nothing waits on the user. Before this change that produced a "Needs input" nobody could answer.
  • Fail-open: if the liveness check fails for permission reasons (Devin running as another user or in a sandbox), the event goes through as it does today. The same applies to the POSIX kill -0 and the listener's check.
  • PID reuse: a new process that happens to reuse an exited owner's PID would briefly count as a live owner. The in-process Pi extension makes the same assumption.
  • Only Devin's hook is guarded. Another Pi bridge that spawns a hook-reporting agent (Claude, Codex) would hit the same shape.
  • Existing installs pick up the new hook script when Orca next starts. SSH hosts get it when their hooks are reinstalled.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason (N/A; see Visual Proof)
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (typecheck, focused tests, and the changed-code gate pass locally; CI covers the full suite)

… Needs input

A Pi extension that runs Devin as a child (pi-devin-acp spawns `devin acp`)
passes Pi's environment down, so Devin's managed hook posted /hook/devin on
Pi's pane. Its PermissionRequest set the pane to waiting after the user had
already approved in Pi's own dialog, and nothing corrected it until Devin
finished.

Pi's status extension already exports its PID as ORCA_PI_STATUS_OWNED (and
Prime's as ORCA_PRIME_AGENT_STATUS_OWNED) to every descendant. The Devin
hook now skips its post while that owner is alive: a numeric guard plus
`kill -0` on POSIX, placed after the payload is read; a presence check that
jumps to the existing stdin drain on Windows, placed after the pane guards.

Fixes stablyai#22011
@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

🧰 Additional context used
📚 Code guidelines (1)
AGENTS.md — auto-discovered

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: f2b70935-e95a-42bb-80b5-bb0a2454fc51

📥 Commits

Reviewing files that changed from the base of the PR and between c01f444 and d944d91.

📒 Files selected for processing (4)
  • .github/workflows/pr.yml
  • config/scripts/pr-code-change-scope.mjs
  • config/tsconfig.cli.json
  • src/shared/agent-hook-listener.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Generated Devin hook scripts now include Pi status-owner environment values in their posts. The listener drops Devin hook payloads when a recorded owner PID is valid and alive. The shared owner-key tuple is used by the hook code and process-owner environment module. Tests cover owner liveness, captured Windows request bodies, and Windows test selection.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to d944d

A rare PID reuse can leave Devin status updates suppressed after the Pi owner exits. The remaining risk is bounded to status reporting; the other reviewed owner-handling paths are consistent.

Security Architecture Review

Security architecture risk: 🔵 Low · up to d944d

The change affects status reporting rather than permission decisions and preserves existing access checks. Unusual inherited values and process-identity recovery remain incompletely established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — An authenticated sender can cause its submitted Devin status record to be ignored by naming any live PID on the receiving host; the check does not prove Pi identity. This decision drops reporting data and uses signal zero for liveness, rather than granting execution authority or terminating a process.

Trust Boundaries and Controls

  • observed — Windows owner values are expanded directly into quoted cmd arguments before curl URL-encodes them. Listener-side numeric validation occurs later and cannot protect this earlier shell boundary. Normal-root stripping and numeric owner assignment provide counterevidence to an attacker-controlled route, but arbitrary inherited-value escaping is not established.

Resilience and Maintainability Implications

  • observed — POSIX suppression follows payload capture, avoiding an early exit before stdin is drained. Listener liveness errors preserve normal processing, and the inspected assertions cover ownerless, live-owner, exited-owner, malformed-owner, and other-provider behavior; those tests were not executed during this review.

Hardening Proposals

  • proposed — Constrain Windows owner values to the intended numeric domain before they enter command syntax, or serialize them without raw cmd expansion. This would reduce the unresolved shell-boundary exposure without relying on later listener validation.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 10 files. (2 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary fix: preventing Devin status events from keeping a Pi pane stuck on "Needs input."
Description check ✅ Passed The description is complete and directly addresses the repository template. It explains the user impact, implementation, rationale, linked issue, testing, platform coverage, risks, and checklist statu…
Linked Issues check ✅ Passed Issue #22011 requires Pi-owned panes to avoid a stale Devin PermissionRequest status. The PR adds shared Pi-owner environment keys, suppresses Devin hook events while a live Pi-family owner exists o…
Out of Scope Changes check ✅ Passed The hook guard changes, listener liveness check, shared environment keys, test coverage, TypeScript inclusion, and Windows test registration support the #22011 fix. The evidence shows no unrelated pro…
Full details: Docstring Coverage

Explanation

Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 10 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — initial review of the 7-file diff at 1a8ef69.

  • New guard module (pi-status-owner-hook-guard.ts) — builds POSIX case/kill -0 and Windows goto-drain guards from the shared PI_STATUS_OWNER_ENV_KEYS, with the malformed-PID and process-group rationale captured inline.
  • Devin hook wiring (hook-service.ts) — POSIX guard sits after payload capture and the spool_hook_event definition, before both its call sites and the curl post; Windows guard sits after the Orca env guards and before the post.
  • Env-key split (pi-process-owner-env.ts) — PI_STATUS_OWNER_ENV_KEYS (the two status keys) extracted as the source for the existing PI_PROCESS_OWNER_ENV_KEYS strip list (which keeps the title marker).
  • Tests + CI lane — new hook-script-pi-status-owner.test.ts runs the generated script against a real listener (and real cmd.exe on Windows), registered in both Windows-lane lists; the stdin-lifecycle rule is narrowed to forbid only missing-ORCA_* guards from routing to the drain.

ℹ️ Platform boundary notes

No change requested — recording these so they are known boundaries rather than surprises.

  • Windows is presence-only. The guard tests that the owner variable is set, not that the PID is alive, so a stale value inherited by a long-lived descendant of an exited Pi keeps Devin quiet where POSIX would post. This matches the PR's own Notes and the deliberate no-tasklist trade-off.
  • POSIX kill -0 proves liveness, not identity. PID reuse could transiently suppress a Devin post. This is the same approximation the in-process extension already makes (isStatusOwnerAlive), so it is consistent, not a regression.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

The Windows Devin hook skipped its post whenever the owner variable was
set, because cmd has no builtin liveness probe. A process that outlived
Pi kept that value, so its Devin events never reached the pane again.

The Windows hook now posts as before and names the owner in two form
fields. The shared hook listener drops a Devin event only while that PID
is running on this host, using the same rules as the POSIX guard (no
leading zero, fail open on any probe error). The owner keys move to
src/shared so the hook builder and the listener share one list.

With no drain jump left, the stdin-lifecycle test returns to its base
form. The guard module is added to the CLI tsconfig, which lists
main-process files explicitly.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — incremental review of 1a8ef69..c01f444 (one commit, 10 files).

  • Moved the Windows skip from the hook script to the listener. The generated devin-hook.cmd no longer goto-drains when an owner variable is merely set; it always posts, attaching ORCA_PI_STATUS_OWNED / ORCA_PRIME_AGENT_STATUS_OWNED as form fields. The shared listener now drops a Devin event only while that PID is actually running.
  • Added hasLivePiStatusOwner (src/shared/agent-hook-listener/pi-status-owner-liveness.ts) to close the platform gap where cmd cannot probe liveness: strictly-numeric PIDs only (0/leading-zero/negative are process-group forms), process.kill(pid, 0) with fail-open on EPERM, matching the POSIX kill -0 guard.
  • Centralized PI_STATUS_OWNER_ENV_KEYS in src/shared/pi-status-owner-env.ts, now consumed by the guard, the process-owner strip list, and the listener so the three stay in sync.
  • Tests updated to assert the new contract: the Windows integration run now feeds real hook posts through the real listener (dropped for a live owner, accepted once it exits or none is named), and a new shared listener test covers malformed owners and confirms non-Devin sources are untouched. The stdin-lifecycle rule was narrowed to just forbid ORCA guards routing to the drain.
  • Lane/tsconfig registration updated for the new module.

I traced the listener drop through the relay and retry paths: the relay re-runs normalizeHookPayload on the raw body, but forwards the normalized envelope (which carries no owner fields), so there is no cross-host PID check; spool records omit the fields; and installRemote stays POSIX-only, so only the local Windows script ever sends them.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b0f476db-d5f5-45b4-9733-c4534cefe259

📥 Commits

Reviewing files that changed from the base of the PR and between 1a8ef69 and c01f444.

📒 Files selected for processing (9)
  • config/tsconfig.cli.json
  • src/main/agent-hooks/pi-status-owner-hook-guard.ts
  • src/main/devin/hook-script-pi-status-owner.test.ts
  • src/main/devin/hook-service.ts
  • src/main/pty/pi-process-owner-env.ts
  • src/shared/agent-hook-listener-pi-status-owner.test.ts
  • src/shared/agent-hook-listener.ts
  • src/shared/agent-hook-listener/pi-status-owner-liveness.ts
  • src/shared/pi-status-owner-env.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

[Medium risk] Prevents child Devin processes from duplicating parent Pi status reports.

The PR is not ready to merge while an interactive Devin permission request can be hidden from the sidebar.

Findings

  1. P1 Permission prompt status disappears ▶

Summary

The PR suppresses Devin hook status events when an inherited Pi-family status owner is alive, using a shell guard on POSIX and listener-side liveness checks on Windows. It also adds cross-platform tests and Windows CI registration.

  • The suppression also hides permission prompts from interactive Devin runs that inherit the owner but do not surface their prompts through Pi.
Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  D[Devin permission request] --> H{Live Pi-family owner?}
  H -->|No| W[Devin hook reports Needs input]
  H -->|Yes| S[Devin event suppressed]
  P[Pi UI prompt event] -->|If emitted| W2[Pi reports Needs input]
  S -->|No Pi UI prompt event| M[Sidebar misses the wait]
Loading

Reviews (1) · Last reviewed commit: "Merge upstream/main into mmarabel/fix-de..."

'#!/bin/sh',
...buildPosixHookPayloadCapture(),
...buildPosixHookSpoolLines('devin'),
...buildPosixPiStatusOwnerHookGuardLines(),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Permission prompt status disappears If Devin runs interactively inside a Pi terminal overlay, inherits Pi’s pane key and live status-owner PID, and does not route its permission prompt through Pi’s UI, this guard skips Devin’s PermissionRequest. Pi then emits no replacement prompt event, so the sidebar never shows “Needs input” for a request the user must answer. The Windows listener drops the same event. Limit suppression to Devin runs whose prompts Pi actually reports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scenario is real and is the trade-off documented in the PR’s Notes. I’m keeping the current behavior: an inherited live Pi/Prime owner PID establishes status ownership, not whether that particular Devin prompt goes through Pi’s UI. Interactive overlay prompts can therefore be absent from the sidebar.

Restoring all nested Devin permission events would reintroduce the ACP stuck-“Needs input” problem this PR fixes. Narrowing suppression reliably needs prompt-routing provenance that the current marker does not provide; I’m not inferring that distinction here.

At unchanged head d944d91da0, src/main/agent-hooks/pi-status-owner-hook-guard.ts:9–11 and src/shared/agent-hook-listener.ts:55–57 implement this policy. Existing real POSIX-hook and listener tests confirm ownerless permission events are reported and live-owner events suppressed: 71 tests pass, one Windows-only test is skipped; full typecheck passes. This is an accepted limitation, not a claim that interactive prompts are covered.

@nwparker

Copy link
Copy Markdown
Contributor

Thanks for the investigation! Nested-agent identity is now handled on main by the nested-hook guards in #29264 and #29386 plus #33572 (the pane's owner reclaims the pane by session). Closing as superseded.

@nwparker nwparker closed this Oct 25, 2026
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.

[Bug]: Pi + devin-acp inner Devin PermissionRequest pins pane to Needs input after ACP approval

2 participants