Repository navigation
[hooks] Map Copilot task and web_search to Task and WebSearch (#690) - #1101
Conversation
(cherry picked from commit 0620955)
PascalCase PreToolUse payloads report tool_name as the Claude tool name, and GitHub's hooks reference maps the runtime task tool to Agent there - so a Task policy still skipped Copilot's task calls under the shape this integration actually registers. (cherry picked from commit 1ef98d7)
The three community fixes for #690 each added `task` and `web_search` to COPILOT_TOOL_MAP; #844 also added `Agent`, the name GitHub's hooks reference gives the `task` tool on PascalCase PreToolUse payloads. This merges their comments into one block that says which payload carries which name, and de-duplicates the tests: the lowercase IDs stay in the permissionRequest test, the `Agent` case keeps its own describe block, and canonical `Task`/`WebSearch` are checked to pass through. handler.test.ts gains `Agent` in its table, an assertion that the table covers every COPILOT_TOOL_MAP key, and a permissionRequest test with `toolName: "task"`, the path where Copilot still sends runtime IDs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
A recorder hook in failproofai's own PascalCase Copilot config shape captured a real `task` call on Copilot CLI 1.0.117: PreToolUse, PostToolUse and PostToolUseFailure report it as `tool_name: "Agent"`, camelCase hooks as `task`, and Copilot's session log (events.jsonl, read by the audit replay) as `task`. permissionRequest fired for the subagent's bash call but not for `task` itself, so the comment no longer claims it does, and the handler test built on that claim is replaced. `web_search` was not offered to the verifying account, so its entries still rest on GitHub's hooks reference. New tests use the captured payloads: an e2e run of the real CLI where a custom policy with `toolNames: ["Task"]` denies the `Agent` PreToolUse and allows the subagent's Bash call (the deny test fails without the `Agent` entry), and a parser test that audits the recorded `task` execution as Task. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
pr-autopilot finished reviewing commit |
hermes-exosphere
left a comment
There was a problem hiding this comment.
Approve: the mappings work through the installed CLI and daemon, audit normalization passes, and all local checks are green. Live Copilot verification remains unavailable.
What the PR says it does
| Claim | Evidence | |
|---|---|---|
| verified | Copilot Agent and task reach policies matching Task. |
Installed-package checks matched both aliases through generated PreToolUse hooks, camelCase payloads, PostToolUse, and PostToolUseFailure, directly and through the daemon. Failure-event checks establish policy matching, not upstream enforcement. |
| verified | Copilot web_search reaches policies matching WebSearch. |
Installed-package checks matched lowercase web_search and canonical WebSearch through direct and daemon evaluation. |
| verified | Copilot session-log task executions normalize to Task for audit replay. |
The installed package’s transcript adapter normalized an eight-call session, preserved raw names and results, and the built CLI audited all eight calls successfully. |
| verified | Subagent Bash calls remain governed by their matching policies. | A Task/WebSearch policy allowed Bash and bash; enabling block-sudo denied a sudo command and allowed an ordinary echo command in both evaluation modes. |
| verified | ask_user, unknown tools, canonical names, and Claude’s Agent preserve their behavior. |
CLI checks allowed ask_user, MCP and unknown names; Task/WebSearch retained canonical matching; Claude Agent did not match the Task policy. |
| verified | The linked issue’s mapping fix has unit coverage and retains contributor authorship. | Read issue #690 and commit history. All requested aliases and assertions are present; commits retain AshSgDe29071999, ZxlDragonDoctor, and lakshya-dhariwal as authors. |
| untested | The documented payload names match live Copilot CLI behavior. | Live Copilot was unavailable without credentials; the kit only drives Codex. GitHub’s hooks-reference URL returned HTTP 403. Captured and synthetic payloads were exercised locally. |
Notes
- No blocking defects found. The change uses the existing normalization path shared by live hooks and audit replay.
- Copilot policies matching raw
Agentnow need to matchTask; the PR description explicitly documents this compatibility change.
What was run
- Read AGENTS.md, relevant CLAUDE.md sections, CONTRIBUTING.md, and /kit/REVIEW.md.
- Read PR metadata, commit messages, issue #690, the complete diff, and surrounding normalization, policy, and audit code.
- Ran /kit/bin/check unit, e2e, lint, tsc, and build.
- Ran python3 /out/kit/verify-copilot.py against the packed CLI and PR daemon.
- Ran COPILOT_HOME=/tmp/kit/home/.copilot bun /out/kit/verify-copilot-audit.ts and packed failproofai audit --scheduled.
- Ran packed-CLI CommonJS, transitive-import, and missing-file checks.
- Used Playwright to inspect policy activity and audit results, capture screenshots, and inspect console/network errors.
- Confirmed git status remained clean.
Reviewed commit 923d684 with gpt-6.1-sol. A person merges.
pr-autopilot · Codex in a locked-down container · traced by failproofai
pr-autopilot review
Approve: the mappings work through the installed CLI and daemon, audit normalization passes, and all local checks are green. Live Copilot verification remains unavailable. What this changes
How this change fitsShared Copilot tool-name normalization flowchart TD
H["Copilot hook payload"] --> E["CLI or daemon worker: evaluateHookEvent"]
E --> C["canonicalizeToolName"]
M["COPILOT_TOOL_MAP: three new aliases"]:::changed --> C
L["Copilot events.jsonl"] --> P["parseCopilotLog"]
P --> A["logEntriesToEvents"]
A --> C
C --> V["Live policy matching"]
V --> S["Decision and activity history"]
C --> R["Audit policy replay"]
R --> D["Audit report"]
classDef added fill:#1f6f3f,color:#fff
classDef changed fill:#7a5a00,color:#fff
What was run against this PR
What the PR says it does
FindingsNo open findings. Rounds
Rewritten after every review, not posted again. Reviewed pr-autopilot · Codex in a locked-down container · traced by failproofai |
Closes #690. Combines the three community PRs for it, #693, #792 and #844, into one change. Each contributor's commits are cherry-picked with
-xand keep their original author.The fix
COPILOT_TOOL_MAPinsrc/hooks/types.tsgains three entries:Agent: "Task"tasktool is called on the PascalCasePreToolUse,PostToolUseandPostToolUseFailurepayloads failproofai registers. Verified live on Copilot CLI 1.0.117, and it matches GitHub's hooks reference. This is the entry live enforcement depends on.task: "Task"events.jsonl) records and failproofai's audit replay reads. camelCase hooks get it too. Verified live on 1.0.117.web_search: "WebSearch"WebSearch, which already passes through. Not verified live: 1.0.117 did not offerweb_searchto the account used.ask_userstays unmapped, which is what all three PRs chose. It has no filesystem or shell reach, so no builtin policy targets it.What came from each contributor
taskandweb_searchentries, their asserts in the lowercase-names test incopilot-canonicalize.test.ts, and the two rows inhandler.test.ts's map table.handler.test.tsrows were identical to #693's, so after the cherry-pick its diff is the comment alone.Agent: "Task"entry and its test. Only #844 found that PascalCase payloads reportAgentrather thantask.Then commits of mine:
taskandweb_searchcases repeated fix: map Copilot task and web_search so Task policies fire #693's asserts, so they are dropped and its describe block keepsAgentplus a pass-through check forTask/WebSearch.handler.test.ts:Agentadded to the table and an assertion that the table covers everyCOPILOT_TOOL_MAPkey (the test is named "every Copilot tool name").toolNames: ["Task"]denies the capturedAgentPreToolUse and allows the subagent's captured Bash call, and a parser test that audits the recordedtaskexecution asTask.Live verification (Copilot CLI 1.0.117)
@github/copilot@1.0.117ran headless (-p,--allow-all-tools) in a scratchCOPILOT_HOME, with a recorder hook in failproofai's own config shape (all 12 PascalCase events) plus camelCasepreToolUse/permissionRequestfor comparison. A prompt that launched a subagent produced:PreToolUse,PostToolUse,PostToolUseFailure(PascalCase)Agent(the subagent's shell call:Bash)preToolUse(camelCase)task(the subagent's shell call:bash)permissionRequestbashonly, never fortasktool.execution_starttaskweb_searchcould not be exercised: 1.0.117 did not offer it to this account, even with--add-github-mcp-tool web_search, and the model usedweb_fetchinstead (already mapped). Its entry rests on the reference.For the reviewer
Agentused to fire on Copilot's PascalCase payloads and now seesTask, as the subagent tool already appears for Factory and Goose. Claude Code's ownAgentstill passes through unmapped. A policy that should catch both should match["Task", "Agent"].Testing
__tests__/hooks/copilot-canonicalize.test.ts,__tests__/hooks/handler.test.tsand__tests__/lib/copilot-sessions.test.ts: 90/90. The new tests fail against main's map.__tests__/e2e/hooks/copilot-integration.e2e.test.ts: 15/15. Without theAgententry, the Task-policy deny test fails.tsc --noEmiton the project pass.Thanks to AshSgDe29071999, ZxlDragonDoctor and lakshya-dhariwal. #693, #792 and #844 are closed in favour of this one.
🤖 Generated with Claude Code
Summary by CodeRabbit
taskasTaskandweb_searchasWebSearch.Taskcan now apply to Copilot subagent hooks, with denial reasons shown when an action is blocked. Subagents’ ownBashcalls remain governed by their matching policies.