Skip to content

Codex plugin: a held call's reason and console link reach the model as well as the person - #8

Merged
davidcrowe merged 3 commits into
mainfrom
agent/job-a6ec8caa
Nov 23, 2026
Merged

davidcrowe merged 3 commits into
mainfrom
agent/job-a6ec8caa

Conversation

@davidcrowe

@davidcrowe davidcrowe commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

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 &amp; 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 identical. A second case asserts it is still deny with ACP_HARNESS=claude-code.
  • native_ask: for deny, ask and allow answers, asserts the PreToolUse request reached the stub and its capabilities does not contain native_ask. The existing check in test/attended.test.mjs is kept.
  • Outage, key-rejected and allow output: that code is unchanged, and all existing tests are kept as they were. Five tests are added, so the count goes up.

…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 `&amp;` 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
davidcrowe marked this pull request as ready for review November 23, 2026 04:18
@davidcrowe
davidcrowe merged commit 5c02cdd into main Nov 23, 2026
1 check passed
@davidcrowe
davidcrowe deleted the agent/job-a6ec8caa branch November 23, 2026 04:18
@davidcrowe davidcrowe changed the title [public repo] Codex plugin: a held call's reason and console link reach the model as well as the person Codex plugin: a held call's reason and console link reach the model as well as the person Nov 24, 2026
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.

1 participant