Multiple autonomous agents, each with a distinct role or specialization, coordinating as peers to solve a problem.
This sample builds peer-collaboration patterns with the Strands Agents SDK and is based off of the AWS Prescriptive Guidance - Multi-agent collaboration pattern.
Prerequisites:
- Python 3.10+
- An AWS account with Amazon Bedrock access
- AWS credentials configured (
aws configure) with permission to invoke models on Bedrock
# Create and activate virtual environment
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Point the sample at your AWS profile and region (loaded by shared/model.py)
cp .env.example .env
# Edit .env: set AWS_PROFILE and AWS_REGION. Optionally pin a model with STRANDS_MODEL_ID.
# Run any of the three collaboration patterns
python swarm_handoff.py # peer specialists hand off by domain
python agents_as_tools.py # an orchestrator consults specialists as tools
python debate_agents.py # a proposer and critic iterate to a better answerNote: Multi-agent systems cost more in both tokens and time to reason. Each agent in this sample is created with a shared
BedrockModelinstance to reduce spin up times.
Try these exercises:
- Watch a handoff chain. Use the swarm handoff to answer a question spanning multiple domains (e.g., "store Bedrock outputs in Amazon DynamoDB") and watch specialists defer to each other.
- See selective consultation. With agents as tools, ask a purely technical question, then a cross-domain business one, and note how many specialists the orchestrator consults each time.
- Follow a debate. Experiment with the debate agents and read how the critic's feedback changes the proposer's answer across rounds.
- Find the decomposition seam. Pick a task and decide whether to split it by role or by context boundary.
In multi-agent collaboration, agents act as peers. Each agent communicates and adapts based on reasoning provided by its peers. This sample shows three patterns: peer handoff with an agent swarm, an orchestrator using agents as tools, and a proposer/critic debate agent.
- Initiates a task: a user or system emits a high-level goal; a manager agent or initiating context defines the objective
- Assigns or discovers roles: agents self-assign or are delegated to roles such as planner, researcher, executor, critic, and explainer
- Communicates with other agents: agents talk through shared memory, message queues, and prompt chaining
- Uses specialized reasoning: each agent applies its own model or domain logic with role-specific prompts and memory
- Coordinates outputs or goals: agents synthesize contributions into a final answer; optionally a supervising agent validates or summarizes
Sample 07 coordinated agents through a central controller running a predefined plan. Multi-agent collaboration is peer-to-peer: agents coordinate among themselves, and the path through them emerges from the problem rather than a fixed sequence.
| Workflow orchestration (Sample 07) | Multi-agent collaboration (Sample 11) | |
|---|---|---|
| Control | Centralized coordinator | Decentralized, role-based peers |
| Interaction | One agent delegates and tracks | Agents negotiate, share, and adapt |
| Design | Predefined sequence of tasks | Emergent, flexible task distribution |
| Best for | Enterprise process automation | Open-ended reasoning and exploration |
The swarm handoff uses the Strands Swarm primitive: peer specialists that hand off to each other based on what the question needs. There is no central router and each agent answers its part and defers the rest:
from strands.multiagent import Swarm
swarm = Swarm([infra_specialist, compute_specialist, database_specialist])
# the handoff chain emerges from the question's domain demandsUse a swarm when each specialist holds factually distinct knowledge and the path through them depends on the question. Split agents by what they know (domain), not by what they do (role).
The agents-as-tools example wraps specialist agents as @tool functions an orchestrator can call. The orchestrator discovers which experts to consult mid-reasoning — a pure technical question might consult one specialist, a complex business decision all three:
@tool
def consult_legal(question: str) -> str:
"""Consult the legal specialist for contract and compliance questions."""
return str(_AGENTS["legal"](question))
orchestrator = Agent(system_prompt=PRIMARY_PROMPT, tools=[consult_legal, consult_financial, consult_technical])This is the collaboration cousin of Sample 07's conditional router: the router picks one path up front, while the orchestrator can consult several specialists dynamically as reasoning unfolds.
The debate agents pit a proposer against a critic across rounds: the proposer offers a solution, the critic challenges it, and they iterate until they converge or hit a round limit. The back-and-forth surfaces flaws a single pass would miss:
# proposer drafts -> critic challenges -> proposer revises -> ... until convergenceUse debate for self-correction and reflective refinement. The adversarial pressure produces a better answer than one agent reasoning alone.
| Pattern | Description | Reference |
|---|---|---|
| Collaboration patterns with Strands | Multi-agent collaboration patterns using Strands Agents and Amazon Nova | Multi-agent collaboration patterns with Strands Agents and Amazon Nova |
| Complex problem solving | Unlock complex problem-solving with multi-agent collaboration on Amazon Bedrock | Unlocking complex problem solving with multi-agent collaboration on Amazon Bedrock |
| Serverless multi-agent systems | Build highly scalable serverless multi-agent systems on AWS with Amazon Bedrock AgentCore | Build highly scalable serverless LangGraph multi-agent systems in AWS with Amazon Bedrock AgentCore |
| Industry multi-agent collaboration | Multi-agent collaboration for telecom network operations on Amazon Bedrock | Multi-agent collaboration using Amazon Bedrock for telecom network operations |
- AWS Prescriptive Guidance - Multi-agent collaboration
- Strands multi-agent: Swarm
- Strands multi-agent: Agents as Tools
- Amazon Bedrock User Guide
This sample is one of eleven, one per pattern in the AWS Prescriptive Guidance on agentic AI patterns. Each has a hands-on sample repository.
| # | Pattern | Sample |
|---|---|---|
| 01 | Basic Reasoning Agents | sample-basic-reasoning-agents |
| 02 | Tool-Based Agents (Functions) | sample-tool-based-agents-functions |
| 03 | Tool-Based Agents (Servers) | sample-tool-based-agents-servers |
| 04 | Computer-Use Agents | sample-computer-use-agents |
| 05 | Coding Agents | sample-coding-agents |
| 06 | Speech and Voice Agents | sample-speech-voice-agents |
| 07 | Workflow Orchestration Agents | sample-workflow-orchestration-agent |
| 08 | Memory-Augmented Agents | sample-memory-augmented-agents |
| 09 | Simulation and Test-Bed Agents | sample-simulation-testbed-agents |
| 10 | Observer and Monitoring Agents | sample-observer-monitoring-agents |
| 11 | Multi-Agent Collaboration | this repository |
See CONTRIBUTING for more information.
This library is licensed under the MIT-0 License. See the LICENSE file.
