02 Attach tools to agents
Before you start
Complete 01 Define a tool. You should know how to construct a Tool with name, description, input_schema, and execute.
Concept
Tools attach to agents, not directly to workflows. Pass a tuple of Tool instances to the agent constructor:
The workflow still registers agents as steps (or graph nodes). When that step runs, the agent carries its tool list into the runtime.
Rules enforced at construction time:
| Rule | Error if violated |
|---|---|
Each entry must be a Tool instance | Type validation in binding layer |
| Tool names must be unique within one agent | WorkflowConfigurationError on duplicate name |
| At least zero tools is valid | Agents without tools behave like plain prompt steps |
Multiple agents in one workflow can each carry different tool sets. A researcher might have no tools while a worker agent exposes several.
The stub provider may not exercise every tool call path the way a live model does. Tool attachment validation still runs, and integration tests confirm the wiring end to end.
Example
Two tools on one agent in a single-step workflow:
Save as attach_tools.py:
Run:
Verify
| Check | Expected |
|---|---|
| Script completes | No configuration error |
| Duplicate tool names | Second tool with same name on one agent raises WorkflowConfigurationError |
Duplicate name check:
Next
03 Tool loop and max iterations bounds how many tool rounds an agent may take in one step.