Files
clawmates/papers/dynamic-agentic-topologies.md
T
Omar SobhandClaude Opus 4.8 2fcec622fb
ci / gates (push) Has been cancelled
ci / rust (push) Has been cancelled
ci / sandbox-k8s (push) Has been cancelled
ci / frontend (push) Has been cancelled
ci / e2e (push) Has been cancelled
paper §7.4: complete 8-cell topology×model grid (Gemini folded in)
Gemini's project-wide key-restriction 403 is cleared (key restricted to the
Generative Language API), so Gemini rejoins the grid. Full 2×4 ranking
(pipeline/debate × Claude/GLM-4.7/Gemini/heterogeneous), judge-ranked 1-8:
D2 > P2 > P3 > P1 > D3 > PG > DG > D1.

Adds a third finding: model strength is task-dependent — Gemini-2.5-flash
placed 2nd on the §7.3 concision brief but 6th-7th here on reasoning
("generic list", "idea repeated"): concise-but-shallow. Reinforces that the
optimal config is a joint choice over {topology × per-role model × task}.
Gemini cells ran via the durable async run path (enqueue → worker → poll).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-18 08:23:52 -07:00

289 lines
16 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Dynamic Agentic Topologies: Safe, Switchable Organizational Patterns for Multi-Agent Systems
**Status:** working draft. Framework, architecture, and the safety result are
implemented (`crates/cm-topology`, `crates/cm-orchestrator`); the empirical
tables below are **preliminary, offline (deterministic scripted provider)** and
are placeholders for runs against production models.
**Author:** Omar Sobh · **System:** ClawMates
---
## Abstract
The performance of a multi-agent system depends not only on its agents but on
their **organizational topology** — how work is decomposed, delegated, and
recombined. Prior work shows the best topology is task-dependent and can be
searched or evolved (ADAS, DarwinGödel, SwarmAgentic). Those systems, however,
largely *simulate* execution and offer no safety contract. We present **Dynamic
Agentic Topologies**, a platform that (1) represents organizational topologies as
typed graphs, (2) executes a task under any topology on a **real, pertenant,
humanintheloopsafe runtime**, and (3) compares topologies empirically on a
quality/cost Pareto front. Our central design result: because a topology is only
an *orchestration over safe agent turns*, **switching topology cannot escalate an
agent's authority** — every sandboxleaving action remains gated by the same
approval/secretbroker/audit layer regardless of structure. This makes topology a
*free variable* teams can tune for results without trading away safety.
## 1. Introduction
Builders of agentic systems face two coupled questions: *which agents?* and *how
are they organized?* The second — the topology — is underexplored in production
because (a) there is no common vocabulary or runtime for it, and (b) letting
structure vary risks letting authority vary with it. We address both. A team
defines a system once and runs it under hierarchies, pipelines, swarms, meshes,
debates, and more; the platform measures which pattern yields better results for
the task, while a fixed safety contract holds across all of them.
Contributions:
1. **A topology model + classifier** (12 executionmeaningful kinds) as a typed
graph with a structural classifier (§3, §4).
2. **A topology runtime** that executes a task under any topology by sequencing
safe agent turns, with a provable safety invariant (§5).
3. **A comparison harness** producing leaderboards and quality/cost Pareto fronts
(§6), and a *workflowoftopologies* composition (§6.3).
4. A reproducible benchmark and preliminary results (§7).
## 2. Related work
- **ADAS — Automated Design of Agentic Systems** (Hu, Lu, Clune): metaagent
search discovers agent architectures in code.
- **DarwinGödel Machine** (Zhang et al.): openended, selfimproving coding
agents with an archive of stepping stones.
- **SwarmAgentic** (Zhang et al.): languagespace particleswarm optimization over
whole multiagent systems.
- **Autonomous Organizational Evolution** (Sobh): composes the three into
`O(t+1)=DGM(SwarmAgentic(ADAS(O(t))))` for selfmodifying hierarchies.
These establish that topology matters and is searchable. Our work supplies the
missing **safe execution substrate** and an **empirical comparison** layer, and
contributes the safety result that makes topology switching deployable.
## 3. Topology model
A topology is a directed graph `TopologyGraph { kind, nodes, edges }`:
- **Node** = a role slot `{ id, role, level?, attrs }`, bound to a concrete agent
(a "claw") at run time.
- **Edge** = a typed relationship `{ from, to, kind }`,
`kind ∈ {delegates_to, reports_to, pipes_to, peers_with, routes_to, bids_to,
reads_writes}`.
The v1 taxonomy (`TopologyKind`) covers twelve executionmeaningful patterns:
hierarchical, flat, pipeline, swarm, mesh, hubspoke, ring, star/MoE, market,
blackboard, debate, holacratic. Each carries advisory **heuristics** (a default
role distribution + optimization weights). Topologies are imported from a loose
JSON/YAML spec via a normalizing adapter.
## 4. Topology classification
Given a graph, we compute structural metrics — density, degree spread, hub
dominance, average local clustering, connected components, diameter, and a
directed hierarchy score — and score each candidate kind. Clear shapes resolve
with high confidence (tree→hierarchical, line→pipeline, cycle→ring, star→hub
spoke, complete→mesh, empty→flat); "soft" kinds (market/blackboard/debate/
holacratic) are weakly inferred and taken from the declared kind. Classification
lets us import thirdparty org structures and characterize graphs objectively for
the benchmark.
## 5. Safe topology execution (the core result)
A topology run is executed by **sequencing agent turns** according to the
pattern. The runtime is parameterized by a single capability — a `TurnExecutor`
that runs one agent turn — and **has no other capability**: it cannot send email,
move money, or touch files; it can only ask an agent to act. The real executor
wraps ClawMates' pertenant runtime, where every sandboxleaving action is
intercepted and held for human approval, executed via a singleuse secret broker,
and written to an appendonly audit journal (the §15 contract).
> **Invariant (authority is topologyinvariant).** For any topologies `T₁, T₂`
> over the same agents, the set of side effects an agent can cause without human
> approval is identical under `T₁` and `T₂`. *Sketch:* the only effectful path is
> a turn's gated action, which is mediated by the safety layer independently of
> the orchestration order; the orchestrator performs no effects itself. Hence a
> change of topology reroutes *information and decisions* but never *authority*.
This is why topology can be a free variable: teams may search, switch, or evolve
structure to improve results with **no** change to the safety surface. The
runtime journals perstep records and aggregate metrics (tokens, turns, gated
actions, approvals granted/blocked) for analysis.
Execution patterns (v1): five distinct executors cover all twelve kinds —
hierarchical (delegate down / synthesize up; also hubspoke, star/MoE, market),
pipeline (staged threading; also ring), swarm (parallel attempts + aggregate;
also flat, holacratic), mesh (two peerexchange rounds + aggregate; also
blackboard), and debate (propose → critique → revise → judge).
## 6. Comparison and composition
### 6.1 Harness
`compare(graphs, task, executor, scorer)` runs the **same task** across a set of
topologies on the **same executor**, scores each output, and returns pertopology
results plus a **leaderboard** (by quality) and a **quality/cost Pareto front**
(maximize quality, minimize tokens), with bestquality and bestvalue picks.
### 6.2 Scoring
Quality is produced by a pluggable `Scorer`. A deterministic length proxy is used
offline; an **LLM judge** (`JudgeScorer`) rates outputs 0100 against the task for
real runs.
### 6.3 Workflow of topologies
`run_workflow(stages, task, executor)` chains whole topology runs, threading each
stage's output into the next (e.g. *swarm* brainstorm → *hierarchical* execute →
*debate* review). Each stage is itself a safe run, so the §5 invariant holds at
every step.
## 7. Preliminary results (offline, illustrative)
Single task ("draft a gotomarket launch plan"), deterministic scripted
provider, lengthproxy scorer. Numbers are placeholders for productionmodel runs.
| Topology | Quality | Tokens | Turns | Pareto |
|--------------|--------:|-------:|------:|:------:|
| Hierarchical | 1.00 | 504 | 4 | |
| Pipeline | 0.92 | 252 | 3 | ★ |
| Swarm | 1.00 | 342 | 4 | ★ |
| Mesh | 1.00 | 1344 | 7 | |
| Debate | 1.00 | 680 | 4 | |
Even in this toy setting the structure of the tradeoff is visible: the efficient
frontier is {Pipeline (best value), Swarm (best quality at low cost)}; mesh's two
peer rounds make it the most expensive; hierarchical and debate are dominated.
### 7.1 Live results (real model + real judge)
We then ran the same harness endtoend against a production model
(**claudesonnet46**) with an LLMjudge scorer (0100 → [0,1]), deployed live,
on the task *"Summarize the top 3 risks of a Q3 developertool launch and
recommend a go/nogo"* with roles {researcher, writer}:
| Topology | Quality | Tokens | Turns | Pareto |
|-----------|--------:|-------:|------:|:------:|
| Debate | 0.840 | 5064 | 4 | ★ |
| Pipeline | 0.790 | 1769 | 2 | ★ |
| Swarm | 0.730 | 3129 | 3 | |
With a real model and judge the tradeoff sharpens and the ranking *changes* from
the offline proxy: **debate** now wins on quality (its adversarial rounds cost
~3× the tokens), **pipeline** is the best value (highest qualitypertoken), and
**swarm is strictly dominated** — it spends more than pipeline for lower quality.
The efficient frontier is {debate, pipeline}. This confirms the central empirical
claim: topology is a real, measurable quality/cost lever, and the winner depends
on whether the user optimizes for quality (debate) or value (pipeline) — a choice
the platform surfaces rather than hardcodes. The §5 safety result is unchanged
across all three: authority is topologyinvariant.
### 7.2 Heterogeneous crossmodel topologies (perrole model selection)
Because a node binds to an agent only at run time, the *model* behind each role is
itself a free variable — orthogonal to topology and to the §5 safety surface. The
platform exposes five subscription/API backends as interchangeable roleagents on a
single runtime — **Claude** (Sonnet4.6), **Kimi** (K2coding), **GLM** (4.7/5.2,
Zhipu), **Gemini** (2.5flash), and **Groq** (Llama3.370b) — each driven by alias
over the runtime gateway. A topology can therefore assign a *different vendor's
model to each role*; assignment is declared per node in the graph
(`node.attrs["agent"]`), so one run request specifies a full heterogeneous cast
with no server reconfiguration.
We ran a fixed 2stage pipeline (drafter → refiner) on *"Draft, then refine, a
onesentence mission statement for a nonprofit teaching coding to refugees"* under
three model assignments, scored by an independent Claude judge for clarity, impact,
and concision:
| Assignment (drafter → refiner) | Judge rank |
|--------------------------------|:----------:|
| GLM4.7 → Gemini2.5flash (heterogeneous) | **1st** |
| Claude → Claude (homogeneous) | 2nd |
| Kimi → Claude (heterogeneous) | 3rd |
The heterogeneous **GLM→Gemini** cast won — the GLM draft plus Gemini's terse
refinement produced the most concise, onbrief statement, beating the homogeneous
allClaude baseline. This is an existence proof of the platform's distinctive
question — *which model wins which role in which topology* — and confirms model
choice is a perrole lever the platform can sweep without touching topology or
safety. (Costs are billed to each vendor's subscription, not pertoken; the run
journal records perstep tokens where the backend surfaces them — Claude/GLM/Gemini
do, the Kimi CLI's stream path does not.) A larger model×role×topology sweep is
future work (§8), bounded by the subscription plans' 5hour/weekly quotas and
concurrency caps, which favor sequential pipelines over wide swarm/mesh fanout.
### 7.3 Perrole model leaderboard (singlerole, fixed task)
To isolate the model axis from topology, we ran a singlerole drafter on a fixed
brief — *"a singlesentence nonprofit mission statement, under 25 words"* — once per
backend (one turn each; pernode model via `attrs["agent"]`), then ranked the
outputs with an independent Claude judge on clarity, impact, and concision:
| Rank | Model (backend) | Note |
|:----:|-----------------|------|
| 1 | **GLM4.7** (Zhipu, Sonnetclass) | tight, vivid, zero wasted words |
| 2 | Gemini2.5flash (Google) | clear; "foster" slightly dilutes |
| 3 | Claude Sonnet4.6 (Anthropic) | strong impact, one clause too many |
| 4 | Kimi K2 (Moonshot) | clear, ending a touch redundant |
| 5 | GLM5.2 (Zhipu, Opusclass) | jargonheavy, longest — *overwrote* the 25word brief |
A notable inversion: the **flagship GLM5.2 ranked last** on this *concisionweighted*
task — its longer, richer output is an asset for complex reasoning but a liability
when the rubric rewards brevity. This is the core lesson the platform is built to
surface: there is no globally "best" model — the winner is role, task, and
rubricdependent, so model choice belongs to the same tunable layer as topology,
measured rather than assumed.
### 7.4 Topology × model grid (the interaction effect)
The platform's defining question is not "best topology" *or* "best model" in
isolation but their **interaction**. We crossed two topologies (**pipeline**, 3
stages; **debate**, propose→critique→revise→judge) with four homogeneous/mixed
model casts (**Claude**, **GLM4.7**, **Gemini2.5flash**, and a heterogeneous
**GLM→Kimi→Claude**) on a fixed decision task — *"Rust or Go for a 3person startup
backend?"* — and ranked all eight final outputs 18 with an independent judge on
reasoning quality, clarity, and concision:
| Topology cast | Claude | GLM4.7 | Gemini | Heterogeneous |
|------------------|:------:|:-------:|:------:|:-------------:|
| **Pipeline** | 4 | **2** | 6 | 3 |
| **Debate** | **8** | **1** | 7 | 5 |
Three results stand out. First, **all eight cells converged on the same decision**
("Go") — so on a task with a clear prior, topology and model move *justification
quality*, not the answer. Second, and central: **the topology × model interaction is
real and nonmonotone.** Debate *amplified* the single strongest model (GLM4.7:
pipeline 2nd → debate 1st, its extra adversarial round adding a hiringcost nuance)
but *degraded* every other cast (Claude: 4th → **dead last**, its judge wasting words
on an "upstream agents agree" metacitation; Gemini: 6th → 7th; heterogeneous: 3rd →
5th). **Debate is not a universal upgrade — it pays off only with a model strong
enough to exploit the extra rounds, and is actively harmful otherwise.** Third,
**model strength is taskdependent, not absolute**: Gemini2.5flash placed *2nd* on
the §7.3 concision brief but *6th7th* here — the judge faulted it for a "generic
list" and "the same idea repeated," i.e. concisebutshallow, an asset for brevity
and a liability for nuanced reasoning. The same model is strong or weak depending on
the role's rubric. Together these confirm the result the platform is built to produce
and that neither a topologyonly nor a modelonly study can see: the optimal
*configuration* is a joint choice over {topology × perrole model × task}, discovered
empirically, with the §5 safety invariant holding across every cell. The sweep ran
sequentially under the subscription plans' quota/concurrency caps, the practical
envelope for this class of experiment.
## 8. Limitations and future work
- Results are offline; the production path (real models + toolusing turns with
live §15 approvals, journaled to `run_events`) is the next integration.
- Several kinds share an executor; richer perkind semantics and the remaining
governance/novel forms are future work.
- **Evolution:** with the comparison harness as a fitness function, an
ADAS/DarwinGödel/qualitydiversity loop can propose and switch topologies —
the bridge to *Autonomous Organizational Evolution* on a safe substrate.
- Product surfaces (a visual topology builder and Pareto explorer) will let
nonexperts run these comparisons.
## 9. Reproduction
```bash
cargo test -p cm-topology
cargo test -p cm-orchestrator --features provider
cargo run -p cm-orchestrator --example topology_bench --features provider
# real models: set ANTHROPIC_API_KEY before the example.
```
Code: `crates/cm-topology` (model/classifier/heuristics), `crates/cm-orchestrator`
(runtime/harness/workflow/judge), `docs/topology-platform.md` (architecture).