docs: add Agent Hooks page and recast Human-in-the-Loop as a before_tool hook#11878
Draft
julian-risch wants to merge 1 commit into
Draft
docs: add Agent Hooks page and recast Human-in-the-Loop as a before_tool hook#11878julian-risch wants to merge 1 commit into
julian-risch wants to merge 1 commit into
Conversation
…ool hook Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
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.
Related Issues
before_toolhook)Proposed Changes:
hooksdict onAgent, the three hook points (before_llm,before_toolwith its re-read-last-message semantics,on_exitwith thecontinue_runflag and the max-steps exception), hook-point validation incl.allowed_hook_points, the reserved state keys hooks interact with (continue_run,tools,hook_context), the@hookdecorator with the three-hook-points example, and class-based hooks withwarm_up/closelifecycle andto_dict/from_dictserialization (LLM-judgeon_exitexample). Added to the sidebar between Agent and Human in the Loop.before_toolhook — the Human in the Loop page now frames HITL as one application of the hooks mechanism:ConfirmationHook(with its tuple-key and"*"-wildcard strategy mapping) replaces the removedconfirmation_strategiesAgent parameter in all examples, the Hayhooks/Open WebUI section points to the generichook_contextrun argument instead of the removedconfirmation_strategy_context, and a new admonition covers the behavior change that strategies see only the model-requested tool arguments (state injection happens at execution time). The Agent page's parameter list swapsconfirmation_strategiesforhooksand addshook_contextto the runtime arguments.How did you test it?
v3code (hatch run python), including a full offlineAgentrun usingMockChatGeneratorwith one hook per hook point: verified firing counts (before_llmtwice for a two-step run,before_toolandon_exitonce),hook_contextandtoolsreadable from state,ValueErroron unknown hook points,ConfirmationHook.allowed_hook_pointsfailing fast underbefore_llm, tuple/wildcard strategy keys, and thatconfirmation_strategies/confirmation_strategy_contextare gone from theAgentAPI.npm run buildindocs-website/passes (also catches broken links, anchors, and sidebar IDs).Notes for the reviewer
Draft PR targeting
v3. Overlap note: the State page's "Reserved keys" admonition (added in #11873) already names the hook-facing keyscontinue_run/tools/hook_contextwithout linking anywhere; this PR documents them in depth on the new Hooks page. Optional follow-up once both are merged: add a link from that State admonition to the Hooks page.With this PR, all 16 subtasks of the tracking issue have draft PRs.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.🤖 Generated with Claude Code