Skip to content

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
v3from
docs/v3-simple-doc-updates-6
Draft

docs: add Agent Hooks page and recast Human-in-the-Loop as a before_tool hook#11878
julian-risch wants to merge 1 commit into
v3from
docs/v3-simple-doc-updates-6

Conversation

@julian-risch

@julian-risch julian-risch commented Jul 5, 2026

Copy link
Copy Markdown
Member

Related Issues

Proposed Changes:

  • feat: Add Agent Hooks #11747 Agent Hooks — new "Hooks" page under Agents: the hooks dict on Agent, the three hook points (before_llm, before_tool with its re-read-last-message semantics, on_exit with the continue_run flag 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 @hook decorator with the three-hook-points example, and class-based hooks with warm_up/close lifecycle and to_dict/from_dict serialization (LLM-judge on_exit example). Added to the sidebar between Agent and Human in the Loop.
  • feat!: Recast HITL as before tool hook #11831 HITL as before_tool hook — 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 removed confirmation_strategies Agent parameter in all examples, the Hayhooks/Open WebUI section points to the generic hook_context run argument instead of the removed confirmation_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 swaps confirmation_strategies for hooks and adds hook_context to the runtime arguments.

How did you test it?

  • Executed against the v3 code (hatch run python), including a full offline Agent run using MockChatGenerator with one hook per hook point: verified firing counts (before_llm twice for a two-step run, before_tool and on_exit once), hook_context and tools readable from state, ValueError on unknown hook points, ConfirmationHook.allowed_hook_points failing fast under before_llm, tuple/wildcard strategy keys, and that confirmation_strategies / confirmation_strategy_context are gone from the Agent API.
  • npm run build in docs-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 keys continue_run / tools / hook_context without 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

🤖 Generated with Claude Code

…ool hook

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
haystack-docs Ready Ready Preview, Comment Jul 5, 2026 8:27pm

Request Review

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