Skip to content

docs: bring hooks reference up to date with new events#2569

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/check-hooks-documentation-for-updates-6c957cfc
Apr 28, 2026
Merged

docs: bring hooks reference up to date with new events#2569
dgageot merged 1 commit intodocker:mainfrom
dgageot:board/check-hooks-documentation-for-updates-6c957cfc

Conversation

@dgageot
Copy link
Copy Markdown
Member

@dgageot dgageot commented Apr 28, 2026

The hooks documentation was lagging behind the runtime. Brings it back in line with what the runtime actually dispatches today.

Doc changes (docs/configuration/hooks/index.md)

  • Hook Types table: was titled "seven hook event types" while listing 11; now lists all 21 events the runtime dispatches. Added turn_start, before_llm_call, after_llm_call, on_error, on_max_iterations, on_agent_switch, on_session_resume, on_tool_approval_decision, before_compaction, after_compaction, plus a callout clarifying the difference between pre_compact and before_compaction.
  • Input fields: replaced the wide matrix (covered 11 events, missing many fields) with a Common Fields + Per-Event Extra Fields layout. agent_name is no longer claimed as a common field (only stop, after_llm_call, and subagent_stop populate it). Adds the previously-undocumented fields: tool_error, last_user_message, from_agent / to_agent / agent_switch_kind, previous_max_iterations / new_max_iterations, approval_decision / approval_source, input_tokens / output_tokens / context_limit / compaction_reason / summary.
  • Output: new Before-Compaction Specific Output section documenting hook_specific_output.summary; new Context-Contributing Events section clarifying transient vs persisted context. Fixed misleading "decision": "allow" example (the field is for blocking only).
  • Plain Text Output: added turn_start to the list of context-contributing events.
  • Per-event narrative subsections for turn_start, before/after_llm_call, before/after_compaction, on_agent_switch, on_session_resume, on_tool_approval_decision. Notification section now points readers at on_error / on_max_iterations.
  • Removed an orphan </div> that was unbalancing the HTML between the LLM-Judge subsection and the CLI Flags section.

Code change (pkg/hooks/events.go)

Added explicit zero-value EventSpec entries for before_compaction, after_compaction, on_agent_switch, on_session_resume, on_tool_approval_decision. Behaviorally a no-op (eventSpec() already falls through to a zero-value EventSpec for unregistered events, which is the right default for these observational events — verified by TestPlainStdoutBecomesAdditionalContext), but it makes eventSpecs (and thus the EventSpecs() accessor) reflect the full set of events the runtime dispatches.

Validation

  • mise lint — clean (golangci-lint, custom lint, go mod tidy)
  • mise test — all packages pass

@dgageot dgageot requested a review from a team as a code owner April 28, 2026 09:27
@dgageot dgageot merged commit b962816 into docker:main Apr 28, 2026
9 checks passed
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.

2 participants