Skip to content

fix(hook): exit 0 stderr context injection not surfaced to LLM #80

Closed

Description

@terisuke

発見元

Codex CLI 監査(2026-04-05 セッション)— コード検証済み

問題

runHooks() (execute.ts:90) は exit 0 の hook から stderr を message として返す。
しかし prompt.ts の PreToolUse/PostToolUse 呼び出し箇所(line 474, 507, 550, 580)は
action === "block" のみチェックし、pass 時の message を破棄している。

Issue #47 の受入基準「exit 0: stderrがあればコンテキスト注入」が未実装。

検証

  • prompt.ts:474: if (hookResult.action === "block") のみ → pass message 無視
  • execute.ts:90: messages.join("\n") で pass message を返却済み
  • E2Eテスト: Hook fired: bash は hook 内で stderr 出力されるが LLM には届かない

対策

pass 時に hookResult.message があれば system-reminder 的にコンテキスト注入:

if (hookResult.message) {
  // Inject as additional context to the tool result
  output.output = `<hook-context>\n${hookResult.message}\n</hook-context>\n${output.output}`
}

重要度: HIGH(Issue #47 受入基準未達成)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions