Conversation
`terminalSequence` is a Claude Code-specific hook output field (added in
2.1.141). Other harnesses run Claude Code-format hooks but reject unknown
keys in hook stdout, so emitting it there turns every hook into a visible
error rather than a notification.
Codex is the concrete case: it maps hooks/hooks.json onto its own event
names and registers all five of this plugin's hooks, but its hook output
schema has no terminalSequence and denies unknown fields. Hooks run with
no controlling tty, so emit_terminal_sequence() falls through to the
JSON branch and the user gets
hook returned invalid post-tool-use JSON output
hook returned invalid user prompt submit JSON output
on every single tool call and prompt submission.
That JSON fallback fires only when CLAUDE_CODE_VERSION is unset. Claude
Code always sets CLAUDE_CODE_VERSION (and CLAUDECODE), so inside Claude
Code the fallback is unreachable; outside it the field is guaranteed
invalid. Gate it on a Claude Code env marker so the guess is only made
where it can pay off.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The problem
terminalSequenceis a Claude Code-specific hook output field (added in CC 2.1.141). Other harnesses run Claude Code-format hooks but reject unknown keys in hook stdout — so emitting it there produces a visible error instead of a notification.Codex is the concrete case. It maps
hooks/hooks.jsononto its own event names and registers all five of this plugin's hooks:Codex runs hooks with no controlling tty, so
emit_terminal_sequence()takes its "unknown CC version" branch, the/dev/ttywrite fails, and it prints the JSON. Codex's hook output schema has noterminalSequenceand denies unknown fields, so the user gets:...on every tool call and every prompt submission. Reproduced directly against all seven scripts — each one emits the field when no tty is available.
The fix
The JSON fallback only fires when
CLAUDE_CODE_VERSIONis unset. Claude Code always setsCLAUDE_CODE_VERSION(andCLAUDECODE), so inside Claude Code that branch is unreachable; outside it the field is guaranteed invalid. Gating it on a Claude Code env marker means the guess is only made where it can pay off.No Codex-specific detection — this fixes any current or future harness that borrows the Claude Code hook format.
Verification
All seven hook scripts, no tty,
WARP_CLI_AGENT_PROTOCOL_VERSION+WARP_CLIENT_VERSIONset:CLAUDECODE, noCLAUDE_CODE_VERSION(Codex)CLAUDE_CODE_VERSION=2.1.278(normal CC path)terminalSequenceJSONCLAUDECODE=1, version unset (the existing hedge)terminalSequenceJSONCLAUDE_CODE_VERSION=2.0.0(old CC)/dev/ttybash -nclean. Plugin version bumped 2.2.0 → 2.2.1 in bothplugin.jsonandmarketplace.json, matching the convention in #73.Note on a related gap
Warp notifications from Codex don't currently work at all — the OSC sequence has no route to the terminal there, since Codex hooks have no tty and no output field for one. This PR only stops the errors. Delivering notifications under Codex would need a separate mechanism, happy to file that as an issue if useful.
🤖 Generated with Claude Code