Preprint · Multi-Agent LLM Systems · Sole-authored

SW-KG

Small-World Topology for Multi-Agent LLM Coordination

Multi-agent LLM systems spend most of their tokens re-sharing context with each other. SW-KG replaces that with a consolidated, FAISS-indexed knowledge graph on a small-world topology - agents read only the subgraph they need. Measured on the Claude API: 91.8% fewer inter-agent tokens (a 12.19× reduction).

Sole-authored preprint · Figshare · DOI 10.6084/m9.figshare.32519487

91.8%
Inter-agent token reduction (measured)
12.19×
Fewer inter-agent tokens vs full-history baseline
10 × 100
Agents × turns, run on the real Claude API
Turn 10
Break-even - SW-KG wins on long-horizon tasks
$14.66
Total API cost of the validation run

The problem

When several LLM agents collaborate on one task, the default is to keep re-sharing the growing conversation. Cost scales with roughly O(A·T²) - every agent, every turn, re-reading everyone's history. Past a few dozen turns, coordination overhead dominates the actual work.

SW-KG attacks this structurally rather than with prompt tricks. Agents communicate over a small-world topology and share knowledge through a single consolidated, FAISS-indexed graph. Instead of re-broadcasting full history, each agent retrieves only the task-relevant subgraph, reasons, and writes its result back through one queue - so the shared memory stays consistent as it grows. A token economy meters what each stored fact is worth, and frequently-read nodes are promoted to hubs.

How it works

Two pipelines over a shared small-world knowledge graph: retrieval (read the subgraph you need) and write-back (fold results in without conflicts).

Retrieval pipeline - complexity target O(A · T · log²N)
Agent query→ANN seed (top-K via FAISS)→BFS expand (score + prune)→Token-budget subgraph→Agent reasons

Retrieval seeds from hub nodes via FAISS approximate-nearest-neighbour lookup, expands with a bounded BFS scored by token value, type match, and recency, then trims to a token budget - so an agent reads a small, relevant slice instead of the whole history. O(A·T·log²N) is the design target; measured scaling on the validation run was near-linear in task length.

Write-back pipeline
Embed output→Dedup (τ)→Contradiction check→Edge + prune→Consolidated primary graph

Results are embedded, de-duplicated against existing nodes, checked for contradictions (contested edges are flagged, not silently overwritten), and linked into the primary graph through a single queue - so concurrent writes never conflict. Facts are promoted to the permanent store only after they've been referenced enough times.

Built in Python on the Anthropic API, with a Watts–Strogatz small-world graph (NetworkX), FAISS retrieval, and a token ledger that meters every prompt and completion. Complexity target: O(A·T²) flat history → O(A·T·log²N) with SW-KG (measured scaling was near-linear).

Measured results

A 10-agent, 100-turn task run on the real Claude API; token counts taken from the run and estimated within ~5%.

Against a full-history baseline, SW-KG cut cumulative inter-agent tokens from 15.0M to 1.23M - a 91.8% reduction (12.19× fewer tokens). The two curves cross at turn 10: before that, maintaining the graph costs more than it saves; after it, the gap widens every turn.

Ablations - what actually drives the savings

Each component removed in isolation, same task, tokens measured. The result includes one that didn't help - reported, not hidden.

Component contribution (final cumulative tokens, turn 100)
  • Full SW-KG: 1.23M tokens
  • Remove the value-ranked (token-economy) retrieval → 1.90M - the value-weighting of stored facts is a substantial driver of the savings
  • Flat store (no consolidated graph) → 2.48M - the largest jump in cost; note this condition changes more than the topology alone, so it does not isolate the small-world property by itself
  • Remove hub compression → 1.18M - slightly cheaper than full SW-KG: on the token metric, hub compression is net-negative, and it's reported as such rather than dropped

Limitations & honest notes

  • Break-even at turn 10. SW-KG is a long-horizon optimization - for short, few-turn tasks the graph overhead isn't worth it.
  • The flat-store ablation doesn't isolate the small-world topology. Removing the consolidated graph changes several things at once, so the 2.48M figure is an upper bound on the combined effect, not a clean measure of topology alone. Isolating it is open work.
  • Hub compression was net-negative on the token metric in isolation (ablation above). It stays in the writeup because a component that didn't help is still a result.
  • Empirical scaling was near-linear in task length on the validation run - weaker than the O(A·T·log²N) target the design aims at.
  • Token counts are estimated within ~5% using a BPE approximation (~4 chars/token) that tracks Claude's tokenizer; the validation run itself was on the real API ($14.66, ~16.2M tokens total).
  • Single-task validation. Results are from one 10-agent, 100-turn coordination task; an out-of-domain probe transferred weakly (small token reduction, no accuracy change), so broader task diversity is future work.

Why it matters for agent teams

Cost at scale

Coordination is the bottleneck

As agent count and task length grow, re-sharing context dominates cost. SW-KG is a concrete pattern for cutting that overhead - the exact problem production multi-agent systems hit.

Memory architecture

Shared graph over flat history

A consolidated, retrieval-indexed graph with conflict-safe write-back is a reusable design for agent memory - not tied to this one task.

Rigor

Measured, ablated, honest

Every number is from a real API run, each component is isolated, and the results that didn't work are reported. That's the evaluation discipline production ML needs.