Documentation Index
Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
Use this file to discover all available pages before exploring further.
Overview
swarms.structs.swarming_architectures is a set of lightweight functions implementing common message-passing topologies between agents. Each function takes a list of Agent objects, a task or task list, and an output_type, then drives the agents through the topology and returns a formatted conversation history.
These are functional building blocks — no shared class, no orchestration object. Reach for them when you want a one-off interaction pattern without instantiating a full swarm class.
| Function | Topology | Per-call shape |
|---|---|---|
circular_swarm | Ring — every agent processes every task in order | (agents, tasks) |
grid_swarm | Agents laid out in a √N×√N grid; one task per cell | (agents, tasks) |
one_to_one | A → B handoff for max_loops turns | (sender, receiver, task) |
broadcast | One sender → many receivers, async | (sender, agents, task) |
output_type selects via history_output_formatter — "dict" (default), "list", "str", etc.
Installation
circular_swarm()
Every agent runs every task, in order. Each agent sees the running conversation context.Flat list of
Agent instances (or list-of-lists; the function flattens once).Tasks processed sequentially. Each agent runs each task.
Format for the returned conversation history.
ValueError if agents or tasks is empty.
grid_swarm()
Place agents in a √N×√N grid, pop tasks one by one, assign to cells row-by-row.len(agents) is a perfect square and len(tasks) matches the cell count. Extra tasks are dropped; extra agents are idle.
one_to_one()
Two-agent handoff:sender processes the task, receiver processes the sender’s output, repeat for max_loops.
Agent that processes the task first each loop.
Agent that processes the sender’s output.
Task for the sender on the first turn.
Number of sender→receiver round trips.
broadcast()
Async function. One sender produces a message based on the conversation context; every agent inagents then processes the sender’s broadcast independently.
ValueError if sender, agents, or task is empty.
Usage Examples
Circular: Every Agent Reviews Every Document
One-to-One: Generator/Critic Loop
Broadcast: Notify a Pool of Workers
Choosing a Topology
| Pattern | When to use |
|---|---|
circular_swarm | Each agent should see every task and the accumulating context |
grid_swarm | Tasks map cleanly to a 2D layout you already have |
one_to_one | Two-agent loops — generator/critic, proposer/judge |
broadcast | Fan-out where one message needs to reach many workers |