Skip to content

fix(examples): correct hookEventName to UserPromptSubmit in hooks example#894

Open
hanfangyuan4396 wants to merge 1 commit intoanthropics:mainfrom
hanfangyuan4396:fix/hooks-userpromptsubmit-hookEventName
Open

fix(examples): correct hookEventName to UserPromptSubmit in hooks example#894
hanfangyuan4396 wants to merge 1 commit intoanthropics:mainfrom
hanfangyuan4396:fix/hooks-userpromptsubmit-hookEventName

Conversation

@hanfangyuan4396
Copy link
Copy Markdown

@hanfangyuan4396 hanfangyuan4396 commented Apr 29, 2026

Summary

The add_custom_instructions hook callback in examples/hooks.py was returning hookEventName: "SessionStart" in its output, but it is registered under the UserPromptSubmit hook event. This mismatch would cause the response to be interpreted with the wrong hook-specific output schema.

  • Changed hookEventName from "SessionStart" to "UserPromptSubmit" to match the UserPromptSubmit matcher and align with UserPromptSubmitHookSpecificOutput
  • Updated the docstring to accurately describe when the hook fires

Test plan

  • Run python examples/hooks.py UserPromptSubmit and verify Claude correctly receives the additionalContext ("My favorite color is hot pink") and answers the question about favorite color

Align add_custom_instructions hookEventName with the UserPromptSubmit
matcher and UserPromptSubmitHookSpecificOutput.

Made-with: Cursor
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.

1 participant