Overview

Index of @tool decorator examples: sync and async tools, class methods, hooks, instructions, caching, and stop-after-tool-call.

ExampleDescription
Tool DecoratorDefine tool decorator with @tool, including sync and async examples.
Async Tool DecoratorDefine async tools with @tool and stream results via AsyncIterator.
Tool Decorator On Class MethodUse @tool on toolkit class methods, including generators.
Tool Decorator with HookAttach execution hooks to a tool via the decorator pattern.
Tool Decorator With InstructionsAdd tool instructions to guide model usage and output.
Cache Tool CallsCache tool results with cache_results to avoid repeat calls.
Stop After Tool CallReturn a tool result without a further model response.
Toolkit Per-Tool InstructionsVerify per-tool instructions from a bare @tool function and a Toolkit both reach agent._tool_instructions via parse_tools.