What This Example Shows
- How to pass
tools_dictionaryon a per-agent basis inside a swarm - How the same tool schema can be shared across multiple worker agents
- A
ConcurrentWorkflowof two financial analysts that both call a structuredsearch_topictool
Every multi-agent architecture on Swarms accepts the same per-agent
tools_dictionary. The pattern below works identically for SequentialWorkflow, HierarchicalSwarm, AgentRearrange, GroupChat, MixtureOfAgents, and the rest — only the swarm_type changes.Step 1: Setup
Step 2: Define a Shared Tool Schema
Tools follow the OpenAI function-call schema. Define it once and reuse across agents.Step 3: Build the Swarm
Two analysts run concurrently, each equipped with the same tool. Each agent independently decides when to callsearch_topic.
Step 4: Run It
Tools are scoped per-agent, not per-swarm. You can give each worker its own toolset — for example, the Market Analyst could get a
search_topic tool while the Economic Forecaster gets a different fetch_macro_data tool. The swarm orchestrator does not need to know about either.Reuse the Pattern
To switch to a different swarm topology, onlyswarm_type changes:
| Goal | swarm_type |
|---|---|
| Run analysts in parallel | ConcurrentWorkflow |
| Chain them one after the other | SequentialWorkflow |
| Have a director synthesize their output | HierarchicalSwarm |
| Route the task to whichever analyst fits | MultiAgentRouter |
| Vote on the best answer | MajorityVoting |
tools_dictionary on each agent stays exactly the same.