Skip to content

[hooks] Map Copilot task and web_search to Task and WebSearch (#690) - #1101

Merged
NiveditJain merged 8 commits into
mainfrom
claude/combine-690-fc359f
Nov 30, 2026
Merged

NiveditJain merged 8 commits into
mainfrom
claude/combine-690-fc359f

Conversation

@NiveditJain

@NiveditJain NiveditJain commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Closes #690. Combines the three community PRs for it, #693, #792 and #844, into one change. Each contributor's commits are cherry-picked with -x and keep their original author.

The fix

COPILOT_TOOL_MAP in src/hooks/types.ts gains three entries:

Entry Covers
Agent: "Task" What the task tool is called on the PascalCase PreToolUse, PostToolUse and PostToolUseFailure payloads 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" The runtime ID, which Copilot's own session log (events.jsonl) records and failproofai's audit replay reads. camelCase hooks get it too. Verified live on 1.0.117.
web_search: "WebSearch" The runtime ID. Per the reference, PascalCase payloads report WebSearch, which already passes through. Not verified live: 1.0.117 did not offer web_search to the account used.

ask_user stays 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

Commit From Kept
fix: canonicalize Copilot task and web_search tool names #693, AshSgDe29071999 Unchanged: the task and web_search entries, their asserts in the lowercase-names test in copilot-canonicalize.test.ts, and the two rows in handler.test.ts's map table.
fix(hooks): map Copilot task/web_search in COPILOT_TOOL_MAP #792, ZxlDragonDoctor The explanatory comment. Its map entries and handler.test.ts rows were identical to #693's, so after the cherry-pick its diff is the comment alone.
fix(copilot): map task and web_search to canonical Task/WebSearch (#690) #844, lakshya-dhariwal Its comment and a dedicated describe block for tool-name canonicalization.
fix(hooks): canonicalize Copilot PascalCase 'Agent' tool name to Task #844, lakshya-dhariwal Unchanged: the Agent: "Task" entry and its test. Only #844 found that PascalCase payloads report Agent rather than task.

Then commits of mine:

  • One comment block that says which payload carries which name, corrected after the live run.
  • De-duplicated tests: fix(copilot): map task and web_search to canonical Task/WebSearch #844's task and web_search cases repeated fix: map Copilot task and web_search so Task policies fire #693's asserts, so they are dropped and its describe block keeps Agent plus a pass-through check for Task/WebSearch.
  • In handler.test.ts: Agent added to the table and an assertion that the table covers every COPILOT_TOOL_MAP key (the test is named "every Copilot tool name").
  • Tests built from the live captures: an e2e run of the real CLI where a custom policy with toolNames: ["Task"] denies the captured Agent PreToolUse and allows the subagent's captured Bash call, and a parser test that audits the recorded task execution as Task.
  • The CHANGELOG entry, and a merge of main.

Live verification (Copilot CLI 1.0.117)

@github/copilot@1.0.117 ran headless (-p, --allow-all-tools) in a scratch COPILOT_HOME, with a recorder hook in failproofai's own config shape (all 12 PascalCase events) plus camelCase preToolUse/permissionRequest for comparison. A prompt that launched a subagent produced:

Hook Tool name received
PreToolUse, PostToolUse, PostToolUseFailure (PascalCase) Agent (the subagent's shell call: Bash)
preToolUse (camelCase) task (the subagent's shell call: bash)
permissionRequest fired for the subagent's bash only, never for task
Copilot's session log, tool.execution_start task

web_search could not be exercised: 1.0.117 did not offer it to this account, even with --add-github-mcp-tool web_search, and the model used web_fetch instead (already mapped). Its entry rests on the reference.

For the reviewer

  • Behaviour change: a custom policy matching the raw name Agent used to fire on Copilot's PascalCase payloads and now sees Task, as the subagent tool already appears for Factory and Goose. Claude Code's own Agent still passes through unmapped. A policy that should catch both should match ["Task", "Agent"].
  • Merge with a merge commit or rebase to keep AshSgDe29071999, ZxlDragonDoctor and lakshya-dhariwal as the authors of their commits. A squash leaves them as co-authors only.

Testing

  • __tests__/hooks/copilot-canonicalize.test.ts, __tests__/hooks/handler.test.ts and __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 the Agent entry, the Task-policy deny test fails.
  • eslint on the changed files and tsc --noEmit on the project pass.
  • The full unit, e2e and build jobs run in CI on this PR. The forks' PRs never ran the repo's CI workflow.

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

  • Bug Fixes
    • Copilot tool names are now consistently recognized when matching policies, including task as Task and web_search as WebSearch.
    • Policies targeting Task can now apply to Copilot subagent hooks, with denial reasons shown when an action is blocked. Subagents’ own Bash calls remain governed by their matching policies.

AshSgDe29071999 and others added 6 commits November 30, 2026 17:15
COPILOT_TOOL_MAP missed task and web_search, so policies matching
Task silently never fired on Copilot. ask_user is left unmapped:
it has no filesystem or shell reach.

Fixes #690

(cherry picked from commit 3d819ab)
Without these entries a policy matching toolName === Task or
WebSearch silently never fires on Copilot sessions. ask_user is
left unmapped (no filesystem or shell reach).

Fixes #690

(cherry picked from commit 078b599)
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>
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Copilot tool map now canonicalizes task and Agent to Task, and web_search to WebSearch. Tests cover canonicalization, permission handling, session activity, and policy decisions for subagent hooks.

Changes: Copilot tool-name canonicalization

Layer / File(s) Summary
Add and verify canonical tool mappings
src/hooks/types.ts, __tests__/hooks/copilot-canonicalize.test.ts, __tests__/hooks/handler.test.ts, __tests__/lib/copilot-sessions.test.ts, CHANGELOG.md
The map adds task and Agent → Task, and web_search → WebSearch. Tests check the mappings, unchanged canonical names, map-key coverage, and canonical names in permission activity and session events. The changelog documents the mappings.
Test canonical names in Copilot policies
__tests__/e2e/helpers/payloads.ts, __tests__/e2e/hooks/copilot-integration.e2e.test.ts
End-to-end tests check that a Task policy denies an Agent payload with the configured reason and allows the subagent’s Bash payload.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Suggested reviewers: chhhee10

Merge Risk: Minimal · up to 923d6

Copilot subagent and web-search tool calls now map to the canonical Task and WebSearch names, so policies written against those names apply to Copilot sessions. The change is small, additive and tested, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Copilot task and web_search tool names are mapped to the canonical Task and WebSearch names in COPILOT_TOOL_MAP. The changeset matches this. The title omits the additi…
Description check Passed The description follows the repository template. It has a description section that explains the fix and its motivation, and it links issue #690. The Type of Change section is missing: no checkbox is m…
Linked Issues check Passed Issue #690 requires two map entries and a test in __tests__/hooks/. The base-to-head diff of src/hooks/types.ts adds task: "Task" and web_search: "WebSearch" to COPILOT_TOOL_MAP, next to the…
Out of Scope Changes check Passed The source change in src/hooks/types.ts adds three entries, all in COPILOT_TOOL_MAP. Each entry serves the #690 objective that canonical Task and WebSearch policies apply to Copilot sessions. …
Full details: Title check

Explanation

The title names the main change: Copilot task and web_search tool names are mapped to the canonical Task and WebSearch names in COPILOT_TOOL_MAP. The changeset matches this. The title omits the additional Agent-to-Task mapping, which is a secondary but relevant part of the change.

Full details: Description check

Explanation

The description follows the repository template. It has a description section that explains the fix and its motivation, and it links issue #690. The Type of Change section is missing: no checkbox is marked and the template's classification is absent. The checklist is also missing: the description reports lint, tsc and test results in prose, but does not tick the template's checklist items for lint, tsc, test:run and build. These are non-critical gaps, so the description is mostly complete.

Resolution

Optionally mark the Type of Change checkbox (Bug fix) and tick the Checklist items that were verified, including npm run build, which the description does not explicitly confirm locally.

Full details: Linked Issues check

Explanation

Issue #690 requires two map entries and a test in __tests__/hooks/. The base-to-head diff of src/hooks/types.ts adds task: "Task" and web_search: "WebSearch" to COPILOT_TOOL_MAP, next to the existing web_fetch: "WebFetch" entry. The head version of __tests__/hooks/copilot-canonicalize.test.ts asserts canonicalizeToolName("task", "copilot") returns Task and canonicalizeToolName("web_search", "copilot") returns WebSearch, which meets the test requirement. The PR also adds Agent: "Task" for PascalCase payloads, which the issue does not request but the PR justifies with live Copilot CLI 1.0.117 evidence. The ask_user decision is stated in a code comment and in the PR description, and the issue allows either choice when reasoned. Limits: the incremental diff from the previous reviewed head was unavailable, so this result rests on the whole-PR diff and head file read. The e2e and session-log tests were not read directly; their results rely on the PR description.

Full details: Out of Scope Changes check

Explanation

The source change in src/hooks/types.ts adds three entries, all in COPILOT_TOOL_MAP. Each entry serves the #690 objective that canonical Task and WebSearch policies apply to Copilot sessions. The Agent: "Task" entry extends that objective to Copilot PascalCase payloads. The PR states this as a behaviour change: a policy that matches the raw name Agent on Copilot now sees Task. The head test file contains the Agent mapping test and the pass-through checks for Task and WebSearch, which connect to the same map. The CHANGELOG entry and the e2e and session-log tests support the mapping change, based on the PR summary, since their file contents were not read directly. No unrelated source change was identified in the reviewed evidence.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

ESLint analysis is incomplete because its dependency install exceeded the time available for this review.

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

A rabbit checks the tool-name trail,
task becomes Task without fail.
web_search finds its proper name,
And subagent hooks face policy’s frame.
The audit records the mapped call,
Then hops along the garden wall.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 214a110f-4271-4b4f-bb0d-6d79644fc9f9
Commits

Reviewing files that changed from the base of the PR and between c6a738e and 923d684.

Files selected for processing: 6

  • CHANGELOG.md
  • __tests__/e2e/helpers/payloads.ts
  • __tests__/e2e/hooks/copilot-integration.e2e.test.ts
  • __tests__/hooks/copilot-canonicalize.test.ts
  • __tests__/lib/copilot-sessions.test.ts
  • src/hooks/types.ts
Files skipped from review as they are similar to previous changes: 1

  • CHANGELOG.md

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

NiveditJain and others added 2 commits November 30, 2026 17:31
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>
@hermes-exosphere

hermes-exosphere commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

pr-autopilot finished reviewing commit 923d684: approved. The results are in the review and the summary.

@NiveditJain
NiveditJain merged commit f21756e into main Nov 30, 2026
29 checks passed

@hermes-exosphere hermes-exosphere 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.

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 Agent now need to match Task; 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

@hermes-exosphere

Copy link
Copy Markdown
Contributor

pr-autopilot review

Verdict Approved
Head 923d684
Round 1
Ran failproofai kit: the PR's stack booted in 5m 25s
Tests 10 passed · 0 failed · 2 could not run
Findings 0 open · 0 resolved

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

  • Maps Copilot Agent and task to Task, and web_search to WebSearch.
  • Adds coverage for policy matching, captured subagent payloads, and session-log normalization.
  • Documents the fix and preserves the community contributors’ commit authorship.

How this change fits

Shared 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
Loading

What was run against this PR

Result Test How Evidence
✅ pass Full unit suite tests /kit/bin/check unit: 444 files passed; 9,351 tests passed, 11 skipped. Includes all three changed unit-test files.
✅ pass Full e2e suite CLI /kit/bin/check e2e: 394 tests passed, seven skipped; Copilot integration passed 15/15.
✅ pass Type check build /kit/bin/check tsc exited 0.
✅ pass Lint other /kit/bin/check lint exited 0 with five warnings in unchanged files and no errors.
✅ pass Production build build /kit/bin/check build completed package bundles, Next.js production build, and standalone pruning; exit 0.
✅ pass Installed-package policy matching CLI python3 /out/kit/verify-copilot.py: CLI-MAPPING-OK 54. Exercised generated hooks, aliases, canonical names, camelCase fields, neighboring tools, builtin enforcement, and daemon evaluation. Results: /out/kit/pr1101-cli-results.json.
✅ pass Installed-package transcript adapter other COPILOT_HOME=/tmp/kit/home/.copilot bun /out/kit/verify-copilot-audit.ts: PACKAGE-AUDIT-OK 8. Verified normalized names, preserved raw names, cwd, and paired results.
✅ pass Session audit through built CLI CLI Packed failproofai audit --scheduled scanned eight tool calls across one session, reported one block-sudo hit, saved the report, and exited 0.
✅ pass Custom-policy loader regressions CLI Packed CLI validated CommonJS and transitive ESM policies. A missing policy file exited 1 with a concise error and no stack trace.
✅ pass Dashboard evidence UI Playwright verified Task/WebSearch policy rows and the eight-call audit report. Screenshots: /out/screenshots/copilot-canonical-policy-denials.png and /out/screenshots/copilot-session-audit.png. Application requests succeeded; Google Fonts failed DNS resolution. Initial incorrect locator waits were corrected.
⏸️ could not run Docker smoke test other Docker is absent in this container. The kit’s packed-package installation supplied clean-install coverage outside Docker.
⏸️ could not run Live Copilot contract verification other No Copilot credentials or live Copilot driver were available; the hooks-reference URL returned HTTP 403.

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.

Findings

No open findings.

Rounds

Round Reviewed Commits in this round Verdict
1 923d684 3 earlier + b6e490a bc8e324 c6a738e bca4b9e 923d684 Approved

Rewritten after every review, not posted again. Reviewed 923d684 with gpt-6.1-sol. A person merges.

pr-autopilot · Codex in a locked-down container · traced by failproofai

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.

COPILOT_TOOL_MAP is missing task and web_search — Task policies silently never fire on Copilot

5 participants