Intercept and control agent behavior with hooks changedagent-sdk/hooks
Nearest release: v2.1.335, published an hour before upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 2 Dec 2026 22:55 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 2 Dec 2026 23:07 UTC.
Upstream edited
Recorded here
Lines+1added
Lines−1removed
From line
883
where the diff opens
First seen
14 Aug 2026
this site's first read of the page
Recorded edits34to this page, all time
The whole hunk
from line 883, old and new numbered
/
from line 883
883883
884884### Recursive hook loops with subagents
885885
886A `UserPromptSubmit` hook that spawns subagents can create infinite loops if those subagents trigger the same hook. To prevent this:
886A `UserPromptSubmit` hook that spawns subagents can create infinite loops if those subagents trigger the same hook. You can prevent the loop in the following ways:
887887
888888* Use a shared variable or session state to track whether you're already inside a subagent
889889* Scope hooks to only run for the top-level agent session
No line in this hunk matches that.