Skip to content

Improve hook failure diagnostics - #1

Open
Fearvox wants to merge 1 commit into
mainfrom
hook-failure-diagnostics
Open

Fearvox wants to merge 1 commit into
mainfrom
hook-failure-diagnostics

Conversation

@Fearvox

@Fearvox Fearvox commented Jun 8, 2026 •

Copy link
Copy Markdown
Owner

Upstream issue: openai#27052

openai/codex currently limits PR creation to explicitly invited collaborators. This fork PR is a reviewable patch surface that can be linked from the upstream issue.

What

  • Add compact hook failure diagnostics with event type, hook id/name, config source, command, exit/status, and redacted stdout/stderr tails.
  • Classify JSON-producing hook stdout parse failures, including invalid JSON and mixed logs plus JSON.
  • Add focused regression coverage for nonzero exits, invalid JSON stdout, mixed logs plus JSON, and multiple matching hooks where only one hook fails.

Why

Hook failures currently do not give users enough information to identify which hook failed or why. Issue openai#27052 asks for diagnostics that preserve existing hook behavior while surfacing the failed event, source, command, exit status, and relevant output tails.

How

  • Centralize hook failure diagnostic formatting in codex-rs/hooks/src/events/common.rs.
  • Extend JSON hook stdout parsing with explicit failure classifications in codex-rs/hooks/src/engine/output_parser.rs.
  • Thread diagnostics through SessionStart, PostToolUse, PreToolUse, PermissionRequest, UserPromptSubmit, Stop, and Compact hook events without changing successful hook behavior.

Testing

  • cd codex-rs && just fmt
  • cd codex-rs && just test -p codex-hooks
  • cd codex-rs && just fix -p codex-hooks
  • cd codex-rs && just test -p codex-hooks after rebasing onto latest upstream/main

Copilot AI review requested due to automatic review settings June 8, 2026 23:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants