Skip to content

Codex reports UserPromptSubmit as Failed once the hook actually produces output, because its stdout contract is not Claude Code's #451

Closed

Description

@fdaviddpt

Observed against a live codex-cli 0.150.1 install on macOS 15.3.2 arm64, with main at 163bc51 — that is, with both #443 and #444 merged.

Symptom

Codex prints this to the user on every prompt:

hook: UserPromptSubmit
hook: UserPromptSubmit Failed

Nothing is written to .remember/logs/hook-errors.log, and the rest of the pipeline works — the same session extracted 2 exchanges (1 human) and reached the summarizer.

Location

scripts/user-prompt-hook.sh, its context-injection output. The line it emits is the prompt stamp:

[10:54 CEST -- floriandavid]

Mechanism

Run standalone with a Codex-shaped payload and CLAUDE_PROJECT_DIR unset, the hook is healthy — exit 0, stamp on stdout:

$ printf '{"session_id":"…","cwd":"…","hook_event_name":"UserPromptSubmit","prompt":"hi"}' | env -u CLAUDE_PROJECT_DIR PLUGIN_ROOT=$P CLAUDE_PLUGIN_ROOT=$P bash "$P/scripts/user-prompt-hook.sh"
[10:54 CEST -- floriandavid]
EXIT=0

So Failed is Codex's verdict on what the hook wrote, not on how it exited.

The natural experiment that isolates it was run by accident, one merge apart, on the same machine with the same plugin:

Probe Hook behaviour Codex verdict
before #444 hit [resolve] FATAL, exited via its soft-fail arm, printed nothing UserPromptSubmit Completed
after #444 resolved, printed the prompt stamp UserPromptSubmit Failed

The only thing that changed between them is whether the hook emitted stdout. Claude Code treats a UserPromptSubmit hook's plain stdout as additional context to inject — that is exactly what the prompt stamp is for. Codex evidently expects something else on that stream, and treats plain text as a failed hook.

Reasoned, not observed: that Codex specifically wants JSON there. What is observed is that plain-text stdout produces Failed and no stdout produces Completed. The exact contract needs reading against Codex's own hooks documentation before anyone writes a fix.

Why priority:high

It is user-facing on every single prompt, and it says Failed to somebody whose memory plugin is in fact working. This is the inverse of this project's usual defect — not a silent failure but a loud non-failure — and to a Codex user it reads as "this plugin is broken", which costs more adoption than the silence #443 and #444 just fixed.

It also bounds what #410 achieved. Mapping Codex's event names onto the same scripts was necessary and is not sufficient: the events agree, the stdin payload agrees, and the contract on the way out does not. #406's premise was that a shared stdin shape made these hosts compatible. The stdin shape is shared. The stdout shape is not, and nothing had tested it because until #444 landed these hooks never got far enough to write anything.

What would settle it

Read Codex's UserPromptSubmit result contract, then either emit what it expects on that host or suppress context injection there and lose the stamp on Codex only. Which is right is a judgement about whether the stamp earns a host-conditional output path.

Pin the host branch both ways: a Claude Code payload still gets the plain stamp on stdout, a Codex payload gets whatever the fix decides. Pair it with a positive control — asserting "no plain text on stdout" passes just as well when the hook never ran at all.

Part of #406.

Metadata

Metadata

Assignees

Labels

bugpriority:high

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions