Skip to content

fix(hooks): advise results no longer carry permissionDecision allow - #519

Open
abhiishek-sharma wants to merge 1 commit into
griddynamics:mainfrom
abhiishek-sharma:fix/486-advise-no-permission-decision
Open

abhiishek-sharma wants to merge 1 commit into
griddynamics:mainfrom
abhiishek-sharma:fix/486-advise-no-permission-decision

Conversation

@abhiishek-sharma

Copy link
Copy Markdown
Contributor

Fixes #486

What was wrong

toCanonical() in src/hooks/src/runtime/run-hook.ts returned permissionDecision: 'allow' for every advise result. advise is meant as a non-blocking notice, but the allow decision means auto-approve (skips the permission prompt; see the hooks docs under docs/hooks/), and Copilot's contract says to omit the decision for normal flow. So a heads-up from dangerous-actions (for example a credential-file write) or read-once approved the tool call. Cursor got permission: allow too. Only the Codex adapter already dropped it.

What changed

  • toCanonical(): the advise branch now returns additionalContext only, with no permissionDecision. This applies to every IDE and to both PreToolUse and PostToolUse advise results. deny and allow results are unchanged.
  • Updated the existing tests that pinned allow on advise output (dangerous-actions, read-once, md-file-advisory, lint-format-advisory, and the per-IDE e2e read-once tests) to expect no permissionDecision / permission.
  • Added tests/to-canonical.test.ts: checks the canonical shape of an advise result, and that the formatted output for the Copilot, Cursor and Codex adapters and the default one contains no allow decision.

Tests

Run in src/hooks:

  • npm test (tsc, bundle build, vitest): 36 files passed, 1 skipped; 1514 tests passed, 0 failed.
  • npx tsc --noEmit: no errors (also part of npm test).
  • Before the fix (same tests, run-hook.ts reverted): 37 tests failed, including the 4 new ones, so the tests fail without the change.

Not run: no separate lint step exists in src/hooks; no IDE was run live, the e2e tests feed recorded payloads through the real hook runner. I did not bump a version, since src/hooks/package.json has none.

toCanonical() emitted permissionDecision allow for advise results, which
auto-approves the tool call in the IDEs that honor it, and sets
permission allow on Cursor. Emit additionalContext only, leaving the
decision to the IDE's normal permission flow, as the Codex adapter
already does. Update the tests that pinned allow and add a toCanonical
regression test.

Fixes griddynamics#486

Signed-off-by: Abhishek Sharma <abhisheksharmaa1404@gmail.com>
@isolomatov-gd

Copy link
Copy Markdown
Contributor

@abhiishek-sharma thank you for this.

One open problem: we cannot show that the advisory still reaches the model once the decision is removed.

Why it matters: advise exists only to warn the agent. If an IDE drops context that comes without a decision, this change removes the auto-approval but also removes the warning.

Evidence: the repo contracts do not cover this case for pre-tool events.

  • docs/hooks/claude-code.md:36 marks PreToolUse additionalContext advise as documented but not exercised.
  • docs/hooks/copilot.md:245 says PreToolUse additionalContext was not tested.
  • docs/hooks/cursor.md:233-241 lists no additional_context for preToolUse output; the only live observation (fix(hooks): stop Cursor read-once from flagging the first read #426) had permission: "allow" present.

Please show how the advisory reaches the model on these IDEs without a decision, or explain why it is safe as is. One example of evidence: a live run where a repeated read makes read-once return context only, and the model quotes it.

Separately, src/hooks/tests/MANUAL-TEST-CASES.md (lines 209, 224, 229, 289, 321, 416, 435) still shows allow in the expected advise outputs.

This branch has not been deployed

No deployments
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]: hooks advise results emit permissionDecision allow, auto-approving tool calls on Claude Code and Copilot

2 participants