Best Practices & Tips
Best practices and real-world examples for Agency Swarm tools.
Although the tool interface is straightforward and simple to use, there are actually quite a few practices and tricks that you can use to get significantly better results.
Use Chain-of-Thought Prompting for Complex Tools
Use chain-of-thought prompting to allow the agent to think and plan before executing a complex tool.
Provide Hints for the Agent
Based on your tool’s logic, you can provide hints for the agent in tool output on what to do next.
Use Shared State to Control the Tool Flow
Use shared_state
to validate previous actions taken by this or other agents, before allowing it to proceed with the next action.
Use Special Types
Restrict the agent to only use specific values for a field, instead of letting it wander by itself.
or use special Pydantic types like EmailStr
.
Combine Multiple Methods
Combine multiple methods to make your execution flow more readable.
Include a Test Case
Include test cases at the bottom of each tool file.
Next Steps
We highly recommend you explore the resources provided in the Pydantic is all you need section.