What happens when you plan a big project with nobody in charge? Most software stacks assume a single orchestrator. One process holds the state, queues the jobs, and hands out tasks. If that coordinator restarts, the entire workflow stumbles. A new project flips that assumption entirely. It shows how a swarm of AI agents can decompose a goal like "plan a two-week trip to Japan" into a full task tree without any single node holding the complete plan at any moment.

Why Build a Leaderless System?

Centralized planners are easy to reason about. You send a request to a server, it splits the work, and workers report back. The problem is the server becomes a cognitive and physical bottleneck. It owns the truth.

In a distributed setup, truth turns into a shared picture that the network converges on through gossip. This specific Python implementation wires together two distinct concepts. The first is an iterative refinement loop: one agent writes a proposal, another scores it, and a third polishes it. The second is a peer-to-peer networking layer built on libp2p, which lets agents discover each other automatically without a registry or a load balancer. The result is a cluster where peers appear, propose, vote, and execute without anyone playing orchestra conductor.

The Four Roles

The system assigns every participant one of four personalities. You do not need four physical machines. They can coexist on one laptop or spread across a home network. The roles are:

  • Decomposer. This agent receives the top-level goal and proposes a split into subgoals. Because the system runs multiple decomposers in parallel, you might get three different recipes for the same Japan trip. One could break the journey down by geography: Tokyo, Kyoto, Osaka. Another might split by activity: transit, lodging, dining, sightseeing. A third could sequence by day. The network considers all of them.

  • Scorer. These agents act as the editorial board. They inspect a proposed split and rate it. A score reflects whether the subgoals are concrete enough, non-overlapping, and collectively exhaustive. More importantly, a scorer decides if a proposal is good enough to accept. Without its blessing, a split stays in limbo.

  • Executor. Once the tree reaches leaf nodes small enough to act on, executors race to claim them. They do not wait for permission from a central queue. Instead, they use a timestamp protocol to settle who gets dibs on a task. The winner runs the job through a local LLM call and broadcasts the result.

  • Observer. This is the wallflower that every network needs. It listens silently to the gossip, reconstructs the plan tree from the chatter, and prints a readable snapshot. Because it never speaks, it proves an important point: anyone joining late can figure out the entire plan just by overhearing.

Gossip as the Source of Truth

The libp2p layer handles discovery and messaging. Agents find each other through the protocol's built-in peer discovery, then broadcast messages onto a shared topic. There is no database of record, no Redis cache holding the canonical plan.

Each peer keeps its own copy of the plan tree and updates it based on the gossip it hears. When a decomposer broadcasts a proposal, every other node receives it, validates the format, and adds the branch to its local tree. When scorers cast votes, the tally propagates the same way. If two executors publish conflicting claims to the same task, the timestamp protocol resolves the collision. The network settles on the earlier claim and discards the late one.

Over time, the tree grows downward from the original goal through layers of accepted subgoals until it reaches bite-sized tasks. The process resembles a blockchain reaching consensus, except the payload is a travel itinerary or a software spec rather than a ledger of coins.

Voting and the Race to Execute

Democracy is expensive, and this system pays the price in latency. A split only wins if enough scorers agree. That threshold could be a simple majority or a stricter quorum, depending on how you configure the cluster. The decomposers do not stop proposing, so the network often evaluates several competing trees at once. Eventually one reaches the required votes and its subgoals graduate from draft to accepted.

执行器增加了另一层协调机制。由于任务在 gossip 通道上是公开的,多个执行器可能会尝试抢占同一个具有吸引力的叶节点。时间戳协议充当了仲裁机制。每个认领都携带一个单调递增的时间戳,网络会优先认可最早的那个。失败者只需转向下一个可用任务即可。这种方式虽然粗糙,但避免了需要中心化调度器在数据库中锁定行的情况。

设计即韧性

当系统发生故障时,该架构的价值便体现了出来。如果一个分解器在提出一半子目标后崩溃,存活的分解器会继续提供拆分方案。计划不会停滞等待重启。如果一个评分器掉线,只要集群规模设置得当,剩余的投票者仍能达成法定人数(quorum)。

真正的收益在于延迟加入。一个在运行中途启动的新代理不需要快照或...