Skip to content
awesome-applied-ai
← Design problems

06Orchestration & Protocols

Topology and context isolation

Approved: the workload genuinely needs multiple agents. Design the topology for a research task where a supervisor must dispatch 5-20 parallel searches, and explain how you stop the supervisor's context from exploding.

The constraint. Fan-out multiplies context. Twenty sub-agents each returning 10k tokens of findings puts 200k tokens into the supervisor, which is past the point where accuracy degrades measurably regardless of the advertised window — mid-context evidence loses over 30% accuracy, and tool-calling degrades faster than prose retrieval.

Architecture.

  1. 01Sub-agents get private windows and return summaries. This is the whole point of the pattern. A sub-agent may consume 50k tokens internally; the parent sees a bounded, schema-validated result. Enforce the bound structurally — a maxTokens on the returned artifact, not an instruction in the prompt.
  2. 02Return structured artifacts, not prose. A typed result with findings, source IDs, and a confidence field is mergeable and validatable. A paragraph is neither.
  3. 03Write to a shared store, pass references. Sub-agents persist full findings to a blob or table and return handles. The supervisor reads a handle only if it needs the detail. This turns an O(n) context cost into O(1).
  4. 04Merge deterministically. Deduplicate by source ID, sort by confidence, truncate to budget — in code. Using a model to merge twenty results is a second, avoidable, hallucination surface.
  5. 05Bound the fan-out dynamically. Five to twenty is a wide range. Let the supervisor propose, then cap by remaining budget: if 18 searches would exceed the cost ceiling, run the 8 highest-value and say so.

Failure semantics. Decide explicitly what a partial fan-out means. If 3 of 20 sub-agents fail, does the task fail, retry those three, or proceed degraded with an annotation? This must be a policy in code. Left to the model, it will silently proceed and present partial results as complete.

Stack. LangGraph's Send API for dynamic fan-out with a reducer on the merge. Claude Agent SDK subagents if you are on Anthropic and want context isolation without building it. Temporal child workflows when each branch needs independent retry and durability. Object storage or Postgres for the artifact store — the handle-passing tier is the part people skip and then regret.

Where answers fail. Drawing a supervisor-worker diagram without ever saying what crosses the boundary. The topology is trivial; the payload contract is the design.