Skip to content
AgenticAIWiki

← Chapter 44. Hooks and the agent lifecycle

Hooks around the agent loop

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.

Keys: → or J next, ← or K back, Home and End jump, Space toggles auto-play when the diagram has focus.