A Codex 0.173 hook set to block stops the turn and exits 0

John Burns

The turn that was supposed to stop did stop, and the process still exited 0. On Codex CLI 0.173.0, a SessionStart command hook that exited 1 with the failure policy set to block printed a Blocked line, did not run the prompt hook, and left the rollout with no agent message. The same hook, with the policy set to continue, printed Failed, ran the prompt hook, reached the model endpoint, and exited 1. Omitting the policy matched continue. Codex CLI 0.163.0, given the blocking file, also printed Failed and exited 1.

That split is the result. A wrapper that only checks the exit code will treat the blocked turn as success and the continued turns as failure. The zero is the run that never asked the model.

What was executed

Two binaries, one hook, and a new Codex home for each case. The newer binary came from the Linux musl archive on the GitHub release tagged rust-v0.173.0, published 2 December 2026. After extraction it printed codex-cli 0.173.0. Its SHA-256 was fd23df981d9e8453e0ce40dd40017ea0d171bc46d78e47dde3ce793ee31d9d63. That release also ships a package checksum file. The file did not list this musl archive, so the archive hash was recorded and not matched to a published sum. The older binary was the one already on PATH, codex-cli 0.163.0, SHA-256 399ff69c431c066e40de318fba45c2b07f45a76b19939d247ee4828fc70c4215. Both were run on Linux x86_64 on 3 December 2026.

Each case set CODEX_HOME to a directory created for that case. No login command was run. The prompt was an argument, the single sentence asking for the word pong. Standard input was closed. Exec was started with the skip-git-repo check and a working directory flag pointed at an empty repository created for the lab. The account Codex directory was not the home these commands read.

The hook was a short shell script. It appended one line naming the exit code it was about to use, appended the JSON Codex wrote to its standard input, and exited with that code. The hooks file registered the same command for SessionStart and for UserPromptSubmit, with a timeout of 10 seconds. The blocking file set the failure policy to block on both handlers. The other files set continue, omitted the field, or set a value the schema does not define.

Hooks do not run until the definition is trusted. The hooks page says a non-managed hook is skipped until that definition is reviewed, and it documents a bypass flag for automation that has already vetted the command. These cases passed that flag, except for one deliberate omission. The command was written for this lab. The flag is not a general recommendation. Without it, the policy below does not get a chance to run.

Every case also printed the same two warnings: bubblewrap was not on PATH, and the code-mode host binary that sits beside the 0.173.0 archive was not present because only the codex binary had been unpacked. Those warnings do not explain the split. They were present when the turn blocked and when it continued.

The banner on every 0.173.0 run named the model gpt-6.2-sol, approval never, and sandbox read-only. No model flag was passed. That model name is the default this binary printed, not a model that answered.

Block stops the turn

The 0.173.0 blocking case is short. After the version banner and the one-line websocket error failed to connect to Responses WebSocket stage=Unknown, the log printed two hook lines and ended:

hook: SessionStart
hook: SessionStart Blocked

There was no UserPromptSubmit line, no reconnect counter, and no 401. The marker file held one event. Its event name was SessionStart and its source was startup. The second handler never received JSON.

The rollout closed that turn as task_complete. The last agent message was null. The duration was 181 milliseconds. The sandbox policy on the turn context was read-only, and the approval policy was never. The hook JSON from the same run said the permission mode was bypassPermissions. Those are not the same statement. The banner and the turn context describe a read-only sandbox with approvals set to never. The hook field uses a different name. Do not treat the permission mode in the hook payload as proof that the sandbox was disabled.

Exit status was 0. A caller that equates 0 with an answer is wrong on this binary. The model was not asked. The word pong is not in the log. The null agent message is the record that the turn produced no reply.

One websocket error was printed before the Blocked line. Block does not mean the process made no network attempt. It means the turn did not continue. The reconnect loop that the other cases entered never started.

The 0.173.0 release note says supported synchronous command hooks can set the failure policy to block, and that a failed PreToolUse check then prevents the tool from running. This run did not reach a tool call. There was no signed-in model turn, so there was no shell command for a tool hook to see. What it did reach was SessionStart. On this binary, a failed SessionStart handler with the policy set to block stopped the session: the prompt hook did not run, and the turn completed without an agent message. That is narrower than the tool sentence in the note, and it is the event this process actually stopped.

The pull request that added the field says the default remains continue, so existing behavior is preserved, and that block applies the event’s blocking behavior while keeping the failure diagnostics. On SessionStart, the blocking behavior observed here was to end the turn. The diagnostic was the Blocked line, not a nonzero exit.

Continue, and a missing field, do not

The same 0.173.0 binary, a new home, and the policy set to continue printed four hook lines:

hook: SessionStart
hook: SessionStart Failed
hook: UserPromptSubmit
hook: UserPromptSubmit Failed

Both handlers ran. Both exited 1. The status word was Failed, not Blocked. The process then retried the websocket and fell back to HTTPS. The final error was 401 Unauthorized, missing bearer or basic authentication, against the public responses URL. Exit status was 1.

Omitting the policy produced the same pair of Failed lines, the same 401, and exit 1. The schema shipped in the 0.173.0 release defines the failure policy as continue or block, and the handler description says the default is continue. The omitted field matched that default in this run. A hooks file copied from an older example, with no failure-policy key, does not become a blocking hook because the binary is now 0.173.0. The key has to be present, and it has to be the value block.

A successful hook is also not a block. The handler that exited 0, with the policy still set to block, printed Completed for SessionStart and Completed for UserPromptSubmit, then the same 401, and exited 1. Block is the failure policy. An exit of 0 is not a failure. The turn continues. On this host the continuation is an authentication error, because no credential was present. That 401 is the control that shows the turn was not stopped. It is not a login procedure, and it is not a reason to store a token in the lab home.

The marker for the continue case held two events. The marker for the block case held one. That count is a better signal than the exit code. A blocked turn and a turn that never started the hook can both leave a caller looking at a short log. The marker distinguishes them: one event means SessionStart ran and the prompt hook did not; zero events means the command did not run.

0.163.0 accepts the field and does not block

The installed 0.163.0 binary was given the blocking file, the bypass flag, and a new home. It printed SessionStart Failed and UserPromptSubmit Failed. It did not print Blocked. It continued to the 401 and exited 1. Setting the policy to continue, and omitting the field, did the same on that binary.

Strict config on 0.163.0 did not reject the key. The hook still ran, still printed Failed, and the turn still reached the endpoint. A config check that only asks whether 0.163.0 will start is not a check that the block policy is in force. The process starts. The policy is a no-op.

That is the compatibility cut. A hooks file written for 0.173.0 can sit in a 0.163.0 home, pass a strict start, run the command, and still let the turn continue after the command exits 1. If the point of the file is to stop the turn when the check fails, 0.163.0 will not do that for SessionStart. Upgrading the binary is part of enabling the policy, not a later cleanup you can skip because the file already parsed.

The 0.163.0 help text already listed the bypass flag. The flag is not new in 0.173.0. What changed, on the event measured here, is what a failed hook does after it runs. On 0.163.0 the failure is reported and the turn continues. On 0.173.0 the same failure, with the policy set to block, ends the turn and the process exits 0.

An untrusted file never reaches the policy

One 0.173.0 case used the blocking file and did not pass the bypass flag. The marker stayed empty. The log had no hook line. It also had no review warning and no mention of the hooks browser. The turn went through the reconnect loop, printed the 401, and exited 1.

The hooks page says that if hooks need review at startup, Codex prints a warning that tells you to open the hooks browser. This exec invocation did not print that warning. The hook was still skipped. A blocking policy in an unreviewed hooks file did not block. The flag used in the other cases is what made the handler run. In a normal exec, the trust record is the gate in front of the failure policy. A file you just wrote, and have not trusted, is not yet a control.

That gate matters more than the policy value. A deployment that copies a blocking hooks file into a home and then runs exec without the bypass flag, and without a prior trust record, will see the 401 or the model reply and will not see Blocked. The absence of a hook line is the failure. Exit 1, in that case, came from the missing credential, not from the policy.

A bad value is a warning

On 0.173.0, strict config with the policy set to halt did not refuse to start. The log printed a warning that the hooks file failed to parse, naming an unknown variant halt, and saying the expected values were continue or block. The marker stayed empty. The turn continued to the 401 and exited 1.

Strict mode reported the bad value. It did not apply block in its place, and it did not stop the process before the model request. A typo in the policy is closer to a missing hook than to a failed check. If the check must run, confirm the parse warning is absent and confirm the marker gained a line. The warning alone means the handler did not run.

The schema’s enum is the list to copy from. continue and block are the two values. Anything else, on this binary, is a warning plus a turn that proceeds as if the hook were not there. That is a worse outcome than a Failed line. Failed at least proves the command ran. A parse warning proves it did not.

Verification

Use a new Codex home and a hook you wrote. Point the command at that script with an absolute path. Register it on SessionStart. Set the failure policy to block. Pass the bypass flag only if you have already decided the command is safe to run without the trust prompt. Close standard input, or pass the prompt as an argument, so the process is not waiting on a terminal.

Require codex-cli 0.173.0, or a later build that still documents this policy, before you treat Blocked as the expected word. On the binary measured here, a hook that exits 1 produces the SessionStart Blocked line, no second event in the marker, exit 0, and a rollout task_complete whose last agent message is null. If you see Failed, the turn was not blocked. If the marker is empty, the hook did not run, which is what an untrusted file did here. If the log contains the unknown-variant warning, the policy value was not continue or block, and the handler was not executed.

Then change only the policy to continue, or delete the key, and repeat in a new home. On this host those two forms printed Failed, ran UserPromptSubmit, and exited 1 at the unauthenticated model request. That second exit is the evidence the policy was not blocking. Do not use the 401 as a test of an account. It is the evidence that the turn continued.

Read the banner’s sandbox line, and the rollout sandbox policy, if you need the sandbox. Do not read the permission mode out of the hook JSON and stop. In the blocked run those sources disagreed on the name, and the turn context was read-only.

This comparison did not exercise PreToolUse. A failed tool hook with the policy set to block is what the 2 December note describes, and this host had no signed-in model turn in which a tool could be called. The SessionStart result above is not a substitute for that tool test. It is the lifecycle stop this binary applied when the session hook failed. If you need the tool case, sign in on a disposable home, give the model a prompt that must run one known command, and require that the command’s side effect is absent when the hook exits 1 with the policy set to block. That run was not done here.

The shape that produced the block was this, with the lab paths replaced:

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "/bin/sh /<lab>/hook.sh /<lab>/marker 1",
            "timeout": 10,
            "onFailure": "block"
          }
        ]
      }
    ]
  }
}

The same object under UserPromptSubmit is what ran only when the session hook did not block. Keep the command absolute. A relative path depends on the working directory exec was given, and this lab did not test that form.

Sources

  • This host, 3 December 2026, Linux x86_64. Codex CLI 0.173.0, SHA-256 fd23df981d9e8453e0ce40dd40017ea0d171bc46d78e47dde3ce793ee31d9d63, from the rust-v0.173.0 musl archive. Codex CLI 0.163.0, SHA-256 399ff69c431c066e40de318fba45c2b07f45a76b19939d247ee4828fc70c4215. Each case used a new CODEX_HOME. No login. The hook exited 1 or 0 as stated. The bypass flag was passed except in the untrusted case.
  • Codex 0.173.0 release notes, 2 December 2026: https://github.com/openai/codex/releases/tag/rust-v0.173.0
  • Pull request 62831, merged 20 November 2026 and shipped in that release: https://github.com/openai/codex/pull/62831
  • Hooks, including trust and the bypass flag: https://developers.openai.com/codex/hooks