Middleware mental model and hooks
Notebook· 04.01· 120–150 min· Lesson 33 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Explain where the six middleware hooks run in the agent loop:
before_agent,before_model,wrap_model_call,wrap_tool_call,after_model,after_agent. - Predict the execution order when several middleware are stacked (before: in order, after: reversed, wrap: nested).
- Choose between node-style hooks (update state,
jump_to) and wrap-style hooks (short-circuit, retry, change the request). - Debug a failing middleware with tracebacks,
%xmode,%debug,%pdband a reproducible failing cell (this module's Jupyter skill).
Before you start
Module 02 (create_agent, tools) and Module 03 (checkpointers, wrap_model_call in 03.03/03.05).
Python in this lesson
Python guideNew here@property
