Repository navigation
fix(copilot): read the real permission and background-work signals - #17
Merged
Merged
Conversation
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
2 of 3 tasks
nplez1
added a commit
that referenced
this pull request
Sep 22, 2026
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
nplez1
added a commit
that referenced
this pull request
Sep 25, 2026
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
nplez1
added a commit
that referenced
this pull request
Sep 27, 2026
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
nplez1
added a commit
that referenced
this pull request
Sep 29, 2026
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
nplez1
added a commit
that referenced
this pull request
Oct 1, 2026
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
nplez1
added a commit
that referenced
this pull request
Oct 6, 2026
Follow-up to fix/copilot-background-work, verified against live Copilot CLI 1.0.87 hook captures rather than inferred field names. - Permission: a permission_prompt notification no longer blocks once a tool completed since the request (it was auto-approved), while an absent snapshot still blocks so a real prompt is never hidden; also recognise the real camelCase permissionRequest payload, which was misread as a PreToolUse. - Background shells: match mode:"async"/detach:true instead of the invented background/runInBackground/run_in_background fields, register from the start result so an inline-completing async shell is never tracked, and settle on the shell_completed notification or a read_bash/stop_bash result. Matching is by shellId so one shell's completion cannot consume another. - Subagents: count only task/agent with mode:"background" (sync tasks leaked a count and pinned monitoring); consume agent_completed/SubagentStop by an identity-aware count that never touches pending shells. - Attribute a subagent's own session events to the child, not the lead pane, so they cannot replace the lead's prompt/tool or settle it. Fixes stablyai#19780 Fixes stablyai#20810
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ELI5
When Orca runs the GitHub Copilot CLI, it reads Copilot's hook events to decide what an agent pane is
doing. Two of those readings were wrong: Orca raised "Needs attention" for permission checks Copilot
had already allowed by itself, and its "background work" tracker disagreed with whether Copilot was
still busy. This teaches Orca to read the events Copilot actually sends, so a pane shows Working
while Copilot is working and only asks for attention when something is really waiting on you.
What Changed
Before, on a Copilot pane:
/allow-all,--yolo, an allowed path) could flip the pane to"Needs attention" until the next prompt, because Orca blocked on Copilot's async
permission_promptnotification even when no prompt was shown.background shell or subagent was running, because the tracker matched field names Copilot never
sends (
background,runInBackground,run_in_background) and counted everytaskcall asbackground work.
Stopevents were applied to the lead pane (subagents arrive on thesame pane carrying their own session id), so a subagent could replace the lead's prompt or mark the
pane
done.read_bashnever cleared, because Copilotsuppresses
shell_completedin that case, stranding the pane in monitoring.After: Orca reads the signals Copilot CLI 1.0.87 actually sends, matches shells and subagents by
identity, and keeps the pane Working until the last outstanding item settles.
Mechanism:
permission_promptnotification no longer blocks once a tool has completed sincethe request (positive evidence the prompt was never shown); an absent snapshot still blocks, so a
real prompt is never hidden. Also recognises the real camelCase
permissionRequestpayload(
hookName), which was otherwise misread as aPreToolUse.(
<command started in background with shellId: N>), so an async shell that finishes withininitial_wait(which returns inline) is never tracked; settled by theshell_completed/shell_detached_completednotification or by any result that proves the shellstopped (
read_bash/stop_bash). Matching is byshellId, so one shell's completion cannotconsume another.
task/agentwithmode:"background"counts (sync tasks leaked a count);SubagentStart/SubagentStopandagent_completedconsume an identity-aware count and nevertouch pending shells, so a redundant agent completion cannot settle one.
child-scoped — it may contribute background work, but cannot change the pane's prompt, tool, or
state, or settle it.
Why
The previous branch (
fix/copilot-background-work) inferred Copilot's signal names rather thanreading them. Capturing live hook payloads from Copilot CLI 1.0.87 showed that every shell field it
matched was invented, that the
tasktool ismode:"sync"|"background", that a background shell canbe read to completion (suppressing the notification), and that a subagent runs as its own session on
the lead pane. Dropping the
permission_promptsignal outright also regressed real prompts, so thepermission fix keeps blocking but adds the "resolved without the user" evidence instead of removing
the signal.
Linked Issue
Fixes stablyai#19780
Fixes stablyai#20810
Visual Proof
N/A — this changes no layout or new UI. It corrects which existing status a Copilot pane shows:
"Needs attention" becomes Working for auto-approved permission checks, and Working (monitoring) is
held until background shells/subagents settle instead of flipping to Done.
Testing
pnpm tc(all typecheck projects),pnpm run check:code-quality:changed, targetedoxlint.1,300 tests across
src/main/agent-hooks+src/shared/agent-hook-listener.New tests: child-session attribution (including two nesting levels), shell identity tracking
(a subagent shell vs the lead's, unknown completion ignored, redundant agent completion), inline-
async and read-to-completion shells, permission-notification staleness, and a replay of a real
Copilot CLI 1.0.87 nested background capture saved under
src/main/agent-hooks/__fixtures__/.Manual: exercised a real Copilot CLI 1.0.87 on macOS (nested background subagents plus an async
shell read to completion). No Linux/Windows-specific code paths were touched.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Written with DeepSeek V4.1 Flash in the Pi coding agent harness; the author reviewed the diff and ran
the tests.
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Security: no new inputs or trust boundaries; parsing only handles hook payloads already authenticated
and attributed to a pane. Cross-platform: no OS-specific code. SSH/remote: the change is in the
shared hook listener used by main and the relay, so remote panes get the same behavior. Backwards
compatibility: older fields are not required; a missing signal still blocks a permission prompt and
still leaves a shell untracked rather than stranding it.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred) — ranpnpm tc, the changed-code gate, and the affected suites locally; CI covers the full suite/build.