Tools that read state and store
A tool often needs facts the model should not supply, such as who the user is. See how one ToolRuntime parameter gives a tool the conversation state, the run's context, the long-term store and a stream writer.
11 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 11 minutes.
Written from the official documentation
In this module: Models, tools and agents
- Chat models and messagesinit_chat_model, message types, content blocks and tool calls.Pro
- Tools and bind_toolsDefine tools, bind them to a model and run them with ToolNode.Pro
- Tools that read state and storeToolRuntime gives tools state, context, store and a stream writer.Pro
- Structured outputGet typed results with provider or tool calling strategies.Pro
- The agent loop as a graphModel node, tool node and one conditional edge that loops.Pro
- The prebuilt agent: create_agentA ready made agent graph you shape with middleware.Pro