Skip to content
AgenticAIWiki

Hooks around the agent loop

Full screen
tool callallowedresultfeedbackSessionStartload project factsAgentmodel decidesPreToolUsebefore the callBashside effects happen herePostToolUseafter the call

Swipe to change step

Step 1 of 8. A hook is your own code attached to a fixed point in the agent's lifecycle. It runs outside the model. Here SessionStart loads project facts as the session begins. SessionStart (load project facts), highlighted. Agent (model decides). PreToolUse (before the call). Bash (side effects happen here). PostToolUse (after the call). arrow from SessionStart to Agent. arrow from Agent to PreToolUse, labelled tool call. arrow from PreToolUse to Bash, labelled allowed. arrow from Bash to PostToolUse, labelled result. arrow from PostToolUse to Agent, labelled feedback. a facts moving along sm.

In this chapter

  1. 44.1Lifecycle events5 min read
  2. 44.2PreToolUse: block or modify a call7 min read
  3. 44.3PostToolUse: check or log a result5 min read
  4. 44.4Hooks vs prompt instructions5 min read

Chapter check

Already know this? Score 80% or more and you can skip ahead. Each attempt draws 4 questions from 12.

Loading check…