Skip to content

docs: group execution hooks and document all hook contexts#6548

Merged
lucasgomide merged 3 commits into
mainfrom
luzk/hooks-docs-structure
Jul 15, 2026
Merged

docs: group execution hooks and document all hook contexts#6548
lucasgomide merged 3 commits into
mainfrom
luzk/hooks-docs-structure

Conversation

@lucasgomide

@lucasgomide lucasgomide commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

The hooks docs were flat pages in the learn nav, documented hook contexts only for LLM and tool calls, and every example used the legacy decorators. This groups them under a collapsible Execution Hooks nav section, adds step-hooks and execution-boundary-hooks pages documenting every hook context from source, reworks the LLM and tool pages to lead with @on while keeping the legacy decorators visible, and brings the orphaned before-and-after-kickoff-hooks page into the group. Follows up #6518, which has since merged.


Note

Low Risk
Documentation and navigation only; no runtime or API behavior changes in this diff.

Overview
Reorganizes Edge learn docs so Execution Hooks is a collapsible nav group and adds dedicated guides for execution boundaries (EXECUTION_START / INPUT / OUTPUT / EXECUTION_END) and step hooks (PRE_STEP / POST_STEP), including context schemas and @on examples. The overview page now links each interception family to those guides and fixes LLM/tool examples to use rich contexts (ctx.tool_name, ctx.response, etc.) instead of treating everything as ctx.payload.

LLM and tool hook pages are reworked to lead with @on and HookAborted, document unified management (clear_all_hooks, unregister_hook), and keep legacy decorators/APIs as a compatibility section with trimmed duplicate content. Related links move to /edge/en/learn/..., and before-and-after-kickoff-hooks is included in the group.

Reviewed by Cursor Bugbot for commit 191a173. Bugbot is set up for automated code reviews on this repo. Configure here.

The hooks pages sat flat in the learn nav and only documented the LLM
and tool call contexts, with examples built on the legacy decorators.
Groups them under a collapsible "Execution Hooks" section, adds
`step-hooks` and `execution-boundary-hooks` pages covering every hook
context from source, reworks the LLM and tool pages to lead with `@on`
while keeping the decorators, and links the orphaned
`before-and-after-kickoff-hooks` page into the group.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The documentation updates consolidate hook guidance around the @on interception model, add execution-boundary and step-hook guides, revise LLM and tool hook pages, and expand documentation navigation.

Changes

Hook Documentation

Layer / File(s) Summary
Hook model overview and navigation
docs/docs.json, docs/edge/en/learn/execution-hooks.mdx
The overview now describes typed hook contexts, direct field access, mutation and replacement behavior, legacy compatibility, and links to the expanded hook guides.
Execution boundary hooks
docs/edge/en/learn/execution-boundary-hooks.mdx
A new guide documents boundary interception points, payload states, context schemas, execution ordering, crew and flow handling, aborts, rewriting, sanitization, cleanup, and related links.
Step hooks
docs/edge/en/learn/step-hooks.mdx
A new guide documents task and flow-method interception, StepContext, payload handling, output propagation, filtering, abort semantics, cleanup, and related links.
LLM call hook guide
docs/edge/en/learn/llm-hooks.mdx
The guide adopts @on, typed contexts, in-place message mutation, crew scoping, management helpers, updated examples, legacy behavior, and troubleshooting guidance.
Tool call hook guide
docs/edge/en/learn/tool-hooks.mdx
The guide adopts PRE/POST interception points, typed input and result contexts, updated registration and management APIs, guardrail examples, legacy behavior, and troubleshooting guidance.

Suggested reviewers: vinibrsl, gabemilani

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main change: reorganizing execution hooks docs and expanding hook context coverage.
Description check ✅ Passed The description is clearly related to the doc and nav changes, including new hook pages and updated examples.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch luzk/hooks-docs-structure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
docs/edge/en/learn/tool-hooks.mdx (1)

204-221: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Avoid storing timing state in ctx.tool_input
_start_time is forwarded to the tool call, so strictly validated tools can fail on the extra kwarg. Keep timing state in a separate call-scoped store keyed by the shared input dict, then clean it up in POST_TOOL_CALL.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/edge/en/learn/tool-hooks.mdx` around lines 204 - 221, Update the Tool
Usage Analytics example so start_timer stores the timestamp in a separate
call-scoped store keyed by the shared tool-input dictionary, rather than adding
_start_time to ctx.tool_input. In track_tool_usage, retrieve and remove that
stored timestamp during POST_TOOL_CALL while preserving the existing count and
elapsed-time updates.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/edge/en/learn/tool-hooks.mdx`:
- Line 320: Update the two occurrences of “pre hooks” in the tool-hooks
documentation to the hyphenated compound modifier “pre-hooks,” including the
instance near the earlier hook-blocking note and the additional occurrence
around the referenced later line.
- Around line 119-138: Update the Crew-Scoped Hooks example import to include
HookAborted alongside on and InterceptionPoint, so the validate_tool_inputs
method can raise it without causing a NameError when the snippet is copied
independently.

---

Outside diff comments:
In `@docs/edge/en/learn/tool-hooks.mdx`:
- Around line 204-221: Update the Tool Usage Analytics example so start_timer
stores the timestamp in a separate call-scoped store keyed by the shared
tool-input dictionary, rather than adding _start_time to ctx.tool_input. In
track_tool_usage, retrieve and remove that stored timestamp during
POST_TOOL_CALL while preserving the existing count and elapsed-time updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0bdac633-f329-4bed-bb28-dba16454a9a0

📥 Commits

Reviewing files that changed from the base of the PR and between 0e5d0ec and b8cb5dc.

📒 Files selected for processing (6)
  • docs/docs.json
  • docs/edge/en/learn/execution-boundary-hooks.mdx
  • docs/edge/en/learn/execution-hooks.mdx
  • docs/edge/en/learn/llm-hooks.mdx
  • docs/edge/en/learn/step-hooks.mdx
  • docs/edge/en/learn/tool-hooks.mdx

Comment thread docs/edge/en/learn/tool-hooks.mdx
Comment thread docs/edge/en/learn/tool-hooks.mdx
@mintlify

mintlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
crewai 🟢 Ready View Preview Jul 14, 2026, 8:26 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

@mintlify

mintlify Bot commented Jul 14, 2026

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
crewai 🟡 Building Jul 14, 2026, 8:09 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

The new edge-only hooks pages linked each other with versionless paths
like `/learn/step-hooks`, which mintlify resolves against the frozen
default version where those pages do not exist, breaking the CI link
check. Uses the `/en/learn/...` form the other edge pages already use.
The `/en/learn/...` form still resolves against the default frozen
version, where `step-hooks` and `execution-boundary-hooks` do not exist
yet, so the link checker kept failing. Links now use the explicit
`/edge/en/learn/...` form, matching how `consuming-streams.mdx` linked
to edge-only streaming pages before they were frozen.
@lucasgomide
lucasgomide merged commit da9902d into main Jul 15, 2026
56 of 57 checks passed
@lucasgomide
lucasgomide deleted the luzk/hooks-docs-structure branch July 15, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants