Source:
02_agent_with_tools.py · 02-agent-with-tools.tsDefine a tool
Attach tools to an agent
Inspect tool calls
Every tool invocation is captured inresult.meta:
Tips
- Return JSON-serialisable data. Dicts, lists, and primitives work best — the SDK serializes them for the model.
- Keep the docstring / description tight. That text is what the model sees when deciding whether to call the tool.
- Errors are fine. If the function raises, the SDK reports the error to the model so it can recover or report back.
- Parallel by default. If the model issues multiple tool calls in one turn, the SDK runs them concurrently. Disable with
parallel_tool_execution=False(Python) /parallelToolExecution: false(TS) on theAgentif needed.