Skip to content

fix(pabcd-state): send PreToolUse advisories as context only - #333

Merged
lidge-jun merged 1 commit into
lidge-jun:devfrom
LilMGenius:fix/pretool-advisory-context
Oct 31, 2026
Merged

lidge-jun merged 1 commit into
lidge-jun:devfrom
LilMGenius:fix/pretool-advisory-context

Conversation

@LilMGenius

Copy link
Copy Markdown
Contributor

Three PreToolUse advisories never reach the model. Codex rejects their envelope and logs PreToolUse hook returned unsupported permissionDecision:allow on every matching tool call, so the IDLE-EDIT reminder, the SHELL-SUBST-01 advisory and the friction warning are dropped while the user sees a hook failure.

Cause

Codex accepts permissionDecision: "allow" from a PreToolUse hook only together with updatedInput (output_parser.rs unsupported_pre_tool_use_hook_specific_output). Anything else sets invalid_reason, and pre_tool_use.rs then marks the run failed and keeps the hook's additionalContext out of the model's input. A permissionDecisionReason sent without a decision is rejected the same way.

Handler Before After
idle-edit.ts (IDLE-EDIT advisory) allow + additionalContext additionalContext
git-write-guard.ts advise branch (SHELL-SUBST-01) allow + additionalContext additionalContext
friction-gate.ts allow + permissionDecisionReason additionalContext

The tool call still runs in every case. Deny envelopes are unchanged, and spawn-attach-hook.ts keeps its allow, which carries updatedInput.

Validation

  • The built hook with echo "\x`"piped tonode plugins/codexclaw/components/pabcd-state/dist/cli.js hook worktree-guard-pretool: dev00a481f5 returns{"permissionDecision":"allow","additionalContext":"[codexclaw: SHELL-SUBST-01 advisory] ..."}, this branch returns {"additionalContext":"[codexclaw: SHELL-SUBST-01 advisory] ..."}`.
  • The updated assertions in idle-edit.test.ts and git-write-guard.test.ts fail against the old source (2 failures) and pass with the fix; those two files plus hook-e2e.test.mjs (L080 now asserts the friction advice in additionalContext): 49 pass, 0 fail.
  • npm run build regenerated the three dist/ files; node plugins/codexclaw/scripts/gate.mjs: OK.
  • Full npm test on Windows: the same failures on dev and on this branch (Windows path, cxc map and visualize tests). timeout yields staleModel null in subagent-config/test/mcp.test.ts failed once on the branch and passed 3 of 3 alone.

Limits

No hook declaration changed, so installed hooks keep their trust. I did not drive a full Codex session through the hook; the Codex behavior above is read from its source at the linked commit.

- drop permissionDecision allow from the idle-edit, shell-subst and friction advisories, which codex rejects without updatedInput and then discards
- move the friction advice from permissionDecisionReason into additionalContext
- assert the context-only envelope in the unit and hook e2e tests
@github-actions github-actions Bot added the bug Something isn't working label Oct 30, 2026
@lidge-jun
lidge-jun merged commit aee8ece into lidge-jun:dev Oct 31, 2026
14 checks passed
lidge-jun added a commit that referenced this pull request Oct 31, 2026
…notes

docs(pabcd-state): clarify #333 advisory notes
@LilMGenius
LilMGenius deleted the fix/pretool-advisory-context branch October 31, 2026 09:37
This was referenced Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants