fix(hookify): correct field mapping for stop and prompt events#33007
Open
daniel-dallimore wants to merge 1 commit intoanthropics:mainfrom
Open
fix(hookify): correct field mapping for stop and prompt events#33007daniel-dallimore wants to merge 1 commit intoanthropics:mainfrom
daniel-dallimore wants to merge 1 commit intoanthropics:mainfrom
Conversation
Rule.from_dict() was mapping stop and prompt events to field='content', but _extract_field() in rule_engine.py has no handler for 'content' on those events. It uses 'reason' for Stop and 'user_prompt' for UserPromptSubmit, so patterns on stop/prompt rules never matched. Add explicit branches for 'stop' -> 'reason' and 'prompt' -> 'user_prompt' so simple-pattern rules on these events work correctly. Fixes anthropics#32153 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This was referenced Mar 11, 2026
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.
Fixes #32153
Root cause
Rule.from_dict()inplugins/hookify/core/config_loader.pyconverts a simplepatternfield into aConditionby inferring which field to match against based on the event type. Theelsebranch was catchingstopandpromptevents and mapping them tofield='content', but_extract_field()inrule_engine.pyhas no handler forcontenton those events — it expectsreasonfor Stop anduser_promptfor UserPromptSubmit. This caused_extract_field()to returnNone, so pattern matching always silently failed.Fix
Add explicit branches before the
elsefallback:Test plan
event: stopand a simplepattern— verify it now matches when Claude stopsevent: promptand a simplepattern— verify it now matches on user inputevent: bashandevent: filerules continue to work unchanged🤖 Generated with Claude Code