# Dynamic Topology Routing

> Form and dissolve agent connections at runtime per task — chain when work is sequential, fan-out when parallel, clique when debate is needed — instead of committing to a fixed topology upfront.

- **Category**: Agentic AI
- **Subcategory**: Multi-Agent
- **Canonical URL**: https://designpattern.fyi/patterns/dynamic_topology_routing/

---

## Description
**Intent**: Form and dissolve connections between agents at runtime by matching the task to candidate collaborators, instead of committing the multi-agent system to a fixed chain, star, or mesh upfront.
**Context**: A multi-agent system has a pool of specialised agents. Classic designs wire them into fixed topologies — sequential chain, star around an orchestrator, fully connected mesh. Different tasks want different communication structures: some need a tight pipeline, others a wide fan-out, others a small debate among three peers. A topology that fits one task wastes messages or drops needed links on another.
**Solution**: Separate the agent pool from the communication graph over it. For each task or step, a routing layer scores candidate agents against the current subtask — by capability description, embedding similarity, or a learned router — and instantiates only the edges needed. As the task evolves, edges are added and dropped. Approaches range from per-step semantic matching (DyTopo) to treating the whole topology as an optimizable graph trained end-to-end (GPTSwarm).



## Use Cases
- The system serves tasks that genuinely want different communication shapes.
- A fixed mesh is too costly and a fixed chain too rigid for the workload mix.
- Agents carry clear, machine-comparable capability descriptions to route against.
- You can afford a routing decision per task or per step.






## Trade-offs


### Advantages

- Communication cost tracks the task instead of the worst-case topology.

- Each subtask reaches the agents actually suited to it.

- Static chain, star, and mesh remain available as router choices — not replaced, just relativized.

- An optimizable graph can be tuned for accuracy or cost over a workload.




### Considerations & Drawbacks

- The router is a new failure point — a bad routing decision wires the wrong agents together.

- Runtime rewiring adds latency and decision cost to every task.

- A topology that changes shape is harder to trace and reproduce than a fixed one.

- Learned topologies need training data and can overfit benchmarks.







---
**Reference**: [Original Source](https://www.agentpatternscatalog.org/patterns/dynamic-topology-routing/)

