Back
RCreddit.com
21
·8 hr ago·Dev community · RSS

Codex hooks give you no exit status for a shell command. Here is how I record it anyway and block "done" on stale test results.

View original
GitHubModel accessOpen source

Heat trend

Collecting trend data

The percentage is based on available heat signal, not comment count or independent people.

AI summary

A developer encountered a limitation with Codex hooks, noting that the PostToolUse payload for shell commands only provides raw output, making it impossible to determine the exit status (e.g., distinguishing between exit 3 and exit 0). To address this, the developer devised a method to record the exit status and prevent "done" status on stale test results. The solution is available on GitHub at pavangupta352/stalegreen.

While adding Codex support to a tool I wrote, I found that the PostToolUse payload for a shell command is just the raw output. A command that exits 3 looks exactly like one that exits 0.

The fix that works: the PreToolUse hook rewrites verification commands (pytest, pnpm test, tsc, eslint, cargo test, next build, about eighty runners) so they print their own exit status and keep the full output in a log. Codex accepts the rewrite only with an allow decision, so it is given for the verification command and nothing else.

From there the tool records every run as a receipt, tracks edits, and when the agent ends a turn with "all tests pass" on a run that predates its own edits, or that failed, or whose result was hidden, it turns the stop into a continuation prompt asking for a rerun, once per turn.

On my own Claude Code history the stale rate was 26 percent of green claims, and 98 percent of verification runs hid the exit status. I have not measured enough Codex sessions of my own to quote a number there, and the tool has a stats command that replays your rollouts so you can see yours.

npx stalegreen install --codex writes the hooks to ~/.codex/hooks.json; Codex asks you to trust them once through /hooks. It also works as a Claude Code plugin and as a DeepSeek Harness plugin.

https://github.com/pavangupta352/stalegreen

Codex hooks give you no exit status for a shell command. Here is how I record it anyway and block "done" on stale test results. · BuzzRadr