Skip to content

fix: report hooks that block or stop Codex - #767

Merged
EugeneTheDev merged 2 commits into
mainfrom
eugenethedev/hook-block-reason
Nov 16, 2026
Merged

EugeneTheDev merged 2 commits into
mainfrom
eugenethedev/hook-block-reason

Conversation

@EugeneTheDev

@EugeneTheDev EugeneTheDev commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

A Codex hook that blocks or stops the prompt ended the turn with a bare end_turn: no answer, no error, no reason. codex-acp ignored hook/completed, which carries the hook's status and output.

Changes

  • hook/completed with status blocked or stopped becomes a warning, sent the same way as other Codex warnings: a session notice, an AIR sessionFailure advisory, or agent text.
    • The title names the event and what it blocked, for example UserPromptSubmit hook blocked the prompt or PreToolUse hook blocked the tool call.
    • The reason is the hook's output, without context entries.
    • Hooks that complete or fail without blocking send nothing.
  • Advisory ids no longer repeat across prompts. The id counter lived in the per-prompt event handler, so the first advisory of every prompt had the same id and revision. It is now shared, in SessionFailureIds.
  • readme-dev.md documents hook notices.

Testing

  • Reproduced against real Codex with a blocking UserPromptSubmit hook. After the fix, each prompt shows the reason with a distinct id.
  • Tests cover all three warning paths, ACP v2, and distinct ids across prompts.

The wording for events other than UserPromptSubmit was not checked against real Codex.

A blocking UserPromptSubmit hook ended every turn with no answer and no reason (IJAI-6099).
hook/completed with status blocked or stopped now becomes a warning notice, an AIR
sessionFailure advisory, or agent text, with the hook's output as the reason.

Advisory ids are now numbered for the whole adapter process instead of per prompt,
so the first advisory of each prompt no longer reuses the same id and revision.
On Linux Codex can stream the command output before the command completes, and then
the completed update does not repeat it.
@EugeneTheDev
EugeneTheDev merged commit bcf0e92 into main Nov 16, 2026
6 checks passed
@EugeneTheDev
EugeneTheDev deleted the eugenethedev/hook-block-reason branch November 16, 2026 21:39
EugeneTheDev pushed a commit that referenced this pull request Nov 16, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.7.0](v2.6.0...v2.7.0)
(2026-11-16)


### Features

* report delegated tasks as session messages and reference children from
tool calls
([#760](#760))
([6567651](6567651))
* send structured plans as items plan_update when the client supports it
([#752](#752))
([ab7a968](ab7a968))
* show the retry cause as details of the AIR retry warning
([#755](#755))
([e981b3c](e981b3c))


### Bug Fixes

* Map priority mode to fast
([#327](#327))
([52cc518](52cc518))
* report hooks that block or stop Codex
([#767](#767))
([bcf0e92](bcf0e92))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: acp-release-bot[bot] <246668977+acp-release-bot[bot]@users.noreply.github.com>
mrmans0n added a commit to mrmans0n/codex-acp that referenced this pull request Nov 17, 2026
Upstream v2.7.0 (agentclientprotocol#767) replaces the event handler's session failure epoch with
SessionFailureIds, a connection-wide counter that every prompt's event handler
shares so notice and failure ids stay unique across handlers. The pre-prompt
goal subscription still passed this.sessionFailureEpoch, which no longer exists:
typecheck fails, and at run time the first notice or failure of goal work set
before the first prompt throws. It now passes this.sessionFailureIds like the
prompt subscription. Every other line is unchanged from
8f65eb8 (originally
9d2c300).

A new test reports a hook that blocks such goal work (agentclientprotocol#767) as a typed AIR
session failure; it fails with the old argument.
mrmans0n added a commit to mrmans0n/codex-acp that referenced this pull request Nov 17, 2026
Upstream v2.7.0 (agentclientprotocol#760) stops advertising sessionCapabilities.subagents to
standard clients: the scenario baseline now strips it from each recorded
initialize response, and CodexAcpServer imports SessionFailureIds (agentclientprotocol#767) on the
import line next to the patch's SessionInstructions import. The adaptation keeps
upstream's subagents removal next to the patch's _meta.systemPrompt capability
in the baseline and both notes in its comment. The sorted added and removed
lines are identical to 57fdf79 (originally
febcd2b); upstream v2.7.0 does not change the systemPrompt conversion that the
_meta.systemPrompt.append alias feeds.
mrmans0n added a commit to mrmans0n/codex-acp that referenced this pull request Nov 17, 2026
Upstream v2.7.0 (agentclientprotocol#760) adds an initialize test (sessionCapabilities.subagents
only for AIR) at the position of the hook review initialize tests. Both are
kept; the sorted added and removed lines are identical to
2662df6 (originally 2341b05). Upstream's
agentclientprotocol#767 reports hook runs that block or stop Codex from hook/completed
notifications, independently of the hook list and trust review, which v2.7.0
does not touch.
mrmans0n added a commit to mrmans0n/codex-acp that referenced this pull request Nov 17, 2026
Upstream v2.7.0 (agentclientprotocol#767) replaces the event handler's session failure epoch and
per-handler notice counter with SessionFailureIds, one counter per connection
that every prompt's handler shares, and passes it as the fourth constructor
argument. 8aaab39 conflicted there: it kept the epoch string and numbered
client-neutral incidents with the incident counter of its connection-wide
NeutralSessionFailureLedger. Upstream's counter now does exactly that for both
typed forms, with the same <epoch>:<n> id format, so the adaptation:

- takes upstream's SessionFailureIds next to the format (the boolean AIR flag
  of upstream's own callers still means air or none);
- allocates failure and notice ids from it in both forms and drops the
  ledger's now unused incident counter;
- keeps the ledger's revision floor for the neutral form, which upstream does
  not have (a later handler can still re-send <turnId>:error);
- passes this.capabilities.sessionFailureFormat and this.sessionFailureIds
  from the server, including the pre-prompt goal subscription.

With agentclientprotocol#755 the retry warning carries the trimmed Codex additionalDetails as
details; the neutral record follows the AIR lane's title and details rules, as
docs/air-extensions.md already states, so the neutral retry test now expects
them. With agentclientprotocol#767 a hook that blocks or stops Codex is a notice: a neutral client
without session.notices gets it as a _meta.sessionFailure record with kind
notice. New test for that; it and the existing neutral tests fail when the
typed lane is AIR-only, and the later-prompt id test fails with per-handler ids.
Adapted from 8aaab39 (originally 2a1384e).
mrmans0n added a commit to mrmans0n/codex-acp that referenced this pull request Nov 17, 2026
Backport of the shell-approval integration test change in upstream bcf0e92 (agentclientprotocol#767), byte-identical.
Codex can stream the command output before the command completes, and the completed update then
does not repeat it. The test now looks for the output in any update of the command.

`ci` on alas-based branches started failing this test on GitHub runners (pinned @openai/codex
unchanged), while upstream v2.7.0 already carries the fix. On the v2.7.0 sync this commit replays
as an empty pick.
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