fix(#925): context monitor echoes the invoking hook event name (#927)

Read `data.hook_event_name` from the stdin payload and fall back to the
Gemini/non-Gemini heuristic only when the field is absent or blank.
Fixes Claude Code rejecting output with "expected Stop but got PostToolUse"
when the monitor is called by Stop, SubagentStop, or PreCompact hooks.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-06-09 08:42:16 -04:00
committed by GitHub
parent 5670feaef5
commit cf6d3b3be5
3 changed files with 212 additions and 1 deletions

View File

@@ -182,7 +182,8 @@ process.stdin.on('end', () => {
const output = {
hookSpecificOutput: {
hookEventName: process.env.GEMINI_API_KEY ? "AfterTool" : "PostToolUse",
hookEventName: (data.hook_event_name && data.hook_event_name.trim())
|| (process.env.GEMINI_API_KEY ? "AfterTool" : "PostToolUse"),
additionalContext: message
}
};