Context and RunContextWrapper
Your tools and hooks often need data the model should never see, such as a user ID or a database connection. See how one context object travels with a run, how a tool reads it through RunContextWrapper, and what the model can and cannot see.
10 minPro
Checking your access…
Inside this lesson
- An animation you play, pause and step through, with each part saying what it is doing.
- The real code beside it, with the lines for each step lit up.
- Practice mode, where you route each message yourself, and a short quiz.
- About 10 minutes.
Written from the official documentation
In this module: Agents in depth
- Instructions, prompt templates and cloningStatic or dynamic instructions, stored prompts and agent copies.Pro
- Output types and tool use behaviorTyped final output, forced tool calls and when a run stops.Pro
- Lifecycle hooksRun code when agents, tools and model calls start and end.Pro
- Context and RunContextWrapperPass your own data to tools and hooks without showing the model.Pro