Skip to lesson
supraj.dev THE ENGINEERING HANDBOOKS
LEARN / BUILD / VERIFY2026 edition · checked 06 Oct

CHAPTER 22 / 30 · Connect and coordinate

Bound autonomous handoffs in a swarm

Use dynamic coordination selectively and inspect whether handoffs contribute new evidence.

4 min read + practiceWorked exerciseInterview practice

The mechanism

A swarm allows agents to hand work among specialists without a fixed path chosen by the developer. This can suit exploratory tasks where the useful next perspective is uncertain. It also makes execution less predictable: agents may repeat one another, circulate an unresolved question or consume budget without improving the result.

ParcelOps does not need a swarm to read one incident. A more plausible experiment asks a small group to critique a synthetic incident response plan from operational and reliability perspectives. Each agent has a distinct responsibility and no mutation tools. The output remains a proposal for human review.

Shared task
Specialist contribution
Bounded handoff
Stop with evidence or uncertainty

A worked bounded configuration

Optional multi-agent inference; potentially more costly than one agent. The limits below are an example policy for a small experiment, not measured optimal settings.

from strands import Agent
from strands.multiagent import Swarm

operator = Agent(model=model, name="operator", tools=[],
                 system_prompt="Assess operational clarity of the supplied synthetic plan.")
reviewer = Agent(model=model, name="reviewer", tools=[],
                 system_prompt="Identify missing evidence and unsafe assumptions in the plan.")
swarm = Swarm(
    [operator, reviewer],
    entry_point=operator,
    max_handoffs=4,
    max_iterations=6,
    execution_timeout=60.0,
    node_timeout=20.0,
)
# Optional inference: result = swarm("Review this synthetic plan: ...")

A handoff limit caps a kind of orchestration work; it does not establish a precise monetary ceiling. The model, nested calls, tool behavior and timeout semantics still matter. Record total usage and status from the actual run, and do not treat reaching a limit as a successful final review.

Shared context also expands the data visible to each participant. If one specialist should not see a field, do not place that field in shared task context. A role description such as “security reviewer” does not provide a separate permission boundary inside the process.

Practice: detect an unproductive loop

Offline. Create a handoff trace: operator asks reviewer for evidence, reviewer asks operator for the same missing evidence, and the pair repeats. Mark whether each handoff introduces a new fact, a new question or no progress. Define an application-level progress criterion before running a live swarm.

Expected observation: syntactically valid handoffs can produce no useful work. A good terminal result may be “insufficient evidence; request carrier scan,” not another round of debate. Add a repeated-handoff case to the evaluator and compare with a single reviewer agent that receives the same plan.

For an optional experiment, record every handoff, contribution, stop status, latency and token use. Include runs that hit the limit. If the swarm improves prose but increases unsupported claims, that is a trade-off to report, not a reason to discard unfavorable cases.

Troubleshooting and trade-offs

Overlapping role descriptions encourage redundant work. Give each specialist a clear question and expected contribution, but avoid artificial roles that have nothing independent to add. If the task has a known sequence, a graph may be easier to verify. If one agent performs adequately, remove the swarm.

Timeouts should lead to an explicit partial result with the evidence gathered so far. Do not report the last speaker’s confident answer as consensus. Agreement among agents using the same model and context is not independent corroboration.

Interview practice

When is a swarm a better fit than a graph?

When the next useful specialist cannot be specified reliably in advance and dynamic handoffs improve measured results. Use a graph when order and dependencies are known and must be enforced.

Why is agreement among several agents weak evidence of truth?

They may share the same model, context and mistaken assumptions. Agreement is correlated output. Verify claims against independent authoritative evidence and evaluate the final task outcome.

Completion check

Define a progress criterion, handoff budget and partial-result policy. Show an unproductive loop fixture and explain why a simpler single-agent baseline remains part of the experiment.

Sources and version notes

Checked 6 October 2026. Python examples target strands-agents==1.58.0 unless labelled otherwise. Live documentation can change; compare your installed version before adapting an example.

YOUR NEXT STEP

Make the understanding yours.

Use the completion check above. Mark this chapter when you can explain the mechanism and its limits.

Self-assessed reading progress. This does not certify that a lab ran or a system is secure.