Repository navigation
Codex plugin: a held call's reason and console link reach the model as well as the person - #8
Merged
Merged
Conversation
…ch the model as well as the person When the Codex plugin denies a call, the gateway's reason now goes into both `permissionDecisionReason` and `systemMessage`, unchanged. The person sees it, and the model gets it inside "Command blocked by PreToolUse hook: ...". Before this change only `systemMessage` was set, so the model got a deny with no reason and no console link. - `bin/govern.mjs`: a new helper, `denyWithReason(text)`, writes `permissionDecision: "deny"` and puts the same `text` in both fields. The text is passed through as-is: nothing is cut, wrapped or HTML-escaped. - `denyByPolicy(reason)` uses it with `[ACP] Denied by policy: <reason>`. - `ask(reason)` uses it too. Its text is now `[ACP] This call needs a person's approval and Codex cannot ask from a hook, so it is blocked. Approve it in the ACP console, then run it again.`, a blank line, then the gateway reason unchanged. - `ask` now always writes `deny`. Before, it wrote `ask` whenever `ACP_HARNESS` was not `codex`. Codex runs the tool when a hook answers "ask", so a missing env var would have let the call through. This change only makes things stricter. `HARNESS` is still used to skip `updatedInput` injection. The header comment is updated to match. - The outage, key-rejected, scoped-token and allow paths are untouched. Nothing was added to the request body, and `attended` is unchanged. - Versions: `PLUGIN_VERSION` goes from 0.6.9 to 0.6.10, and `.codex-plugin/plugin.json` goes from 0.1.1 to 0.1.2. - These two numbers were already different before this change, so bumping each by one patch can't also make them equal. I bumped each separately and did not align them. - `.agents/plugins/marketplace.json` has no version field, so it is unchanged. - No existing test checks that the versions match. How the new tests in `test/deny-text.test.mjs` cover the acceptance criteria. They run the real hook against a local stub gateway, with a throwaway HOME holding `.acp/credentials`: - **Policy deny with reason `R`:** asserts the decision is `deny` and that `permissionDecisionReason` and `systemMessage` both equal `"[ACP] Denied by policy: " + R`. - **Multi-line reason ending in `https://cloud.agenticcontrolplane.com/a/AB12?x=1&ws=w1`:** asserts both fields equal the expected string exactly and end with that URL, and that `&` appears nowhere in stdout. - **Gateway `ask`:** asserts the decision is `deny`, both fields contain `Codex cannot ask from a hook` and end with the gateway reason unchanged, and the two fields are ident Tracked in the internal tracker.
… model The reason now lands in permissionDecisionReason as well as systemMessage, so drop ANSI/OSC escape sequences, other control characters (keeping newline and tab) and invisible bidi/zero-width characters, cap a runaway reason while keeping its end (the console link), and fall back to the default text when the reason is not a non-empty string. The decision stays deny in every case.
Unpaired surrogates in a reason or PostToolUse notice are replaced with U+FFFD, so the hook never prints a lone surrogate escape a strict JSON parser could reject. An unterminated OSC sequence now stops at a newline or ESC, CSI needs its final byte, and a stray ESC removes only itself, so hostile escapes cannot swallow the console link. The deny output is flushed before exit: a long multi-byte reason was cut short on an asynchronous pipe, leaving unparseable JSON.
davidcrowe
marked this pull request as ready for review
November 23, 2026 04:18
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.
When the Codex plugin denies a call, the gateway's reason now goes into both
permissionDecisionReasonandsystemMessage, unchanged. The person sees it, and the model gets it inside "Command blocked by PreToolUse hook: ...". Before this change onlysystemMessagewas set, so the model got a deny with no reason and no console link.bin/govern.mjs: a new helper,denyWithReason(text), writespermissionDecision: "deny"and puts the sametextin both fields. The text is passed through as-is: nothing is cut, wrapped or HTML-escaped.denyByPolicy(reason)uses it with[ACP] Denied by policy: <reason>.ask(reason)uses it too. Its text is now[ACP] This call needs a person's approval and Codex cannot ask from a hook, so it is blocked. Approve it in the ACP console, then run it again., a blank line, then the gateway reason unchanged.asknow always writesdeny. Before, it wroteaskwheneverACP_HARNESSwas notcodex. Codex runs the tool when a hook answers "ask", so a missing env var would have let the call through. This change only makes things stricter.HARNESSis still used to skipupdatedInputinjection. The header comment is updated to match.attendedis unchanged.PLUGIN_VERSIONgoes from 0.6.9 to 0.6.10, and.codex-plugin/plugin.jsongoes from 0.1.1 to 0.1.2..agents/plugins/marketplace.jsonhas no version field, so it is unchanged.How the new tests in
test/deny-text.test.mjscover the acceptance criteria. They run the real hook against a local stub gateway, with a throwaway HOME holding.acp/credentials:R: asserts the decision isdenyand thatpermissionDecisionReasonandsystemMessageboth equal"[ACP] Denied by policy: " + R.https://cloud.agenticcontrolplane.com/a/AB12?x=1&ws=w1: asserts both fields equal the expected string exactly and end with that URL, and that&appears nowhere in stdout.ask: asserts the decision isdeny, both fields containCodex cannot ask from a hookand end with the gateway reason unchanged, and the two fields are identical. A second case asserts it is stilldenywithACP_HARNESS=claude-code.native_ask: for deny, ask and allow answers, asserts the PreToolUse request reached the stub and itscapabilitiesdoes not containnative_ask. The existing check intest/attended.test.mjsis kept.