Cosmonapse: A Decentralized Multi-Agent Framework Built on an Event Bus

Cosmonapse replaces central orchestrators with a peer-node event bus for decentralized multi-agent AI systems.
Cosmonapse is an open-source multi-agent framework that reimagines agent coordination by treating agents as peers on a shared event bus rather than subjects of a central orchestrator. By modeling tool calls, memory management, and human-in-the-loop approvals as typed signals, it achieves full decoupling between concerns — making execution naturally observable, replayable, and debuggable. It supports Python and TypeScript under the Apache 2.0 license.
From Central Orchestration to Peer-to-Peer Collaboration
As large language models continue to grow in capability, building Multi-Agent Systems (MAS) has become one of the core challenges in AI engineering. Yet the vast majority of frameworks on the market still follow the same design philosophy: a monolithic central orchestrator that uses a while True: control loop to exclusively handle model calls, tool use, memory management, human approvals, and workflow control.
Research into multi-agent systems dates back to the distributed AI field of the 1980s, but it wasn't until the rise of LLMs that MAS entered the mainstream of engineering practice. Leading frameworks today — LangGraph, AutoGen, CrewAI, and others — all rely on the central orchestrator pattern to varying degrees. At its core, a central orchestrator is a "command-and-control" topology rooted in the design traditions of workflow engines and RPA (Robotic Process Automation). Its strengths are predictable execution order and clear debugging paths. But as the number of agents grows and tool call chains lengthen, orchestrator code rapidly balloons into an unmaintainable God Object — the classic anti-pattern in object-oriented design where a single class or module takes on too many responsibilities, resulting in high coupling and low cohesion.
The open-source project Cosmonapse proposes a fundamentally different solution: agents are peers on a shared event bus. Any node can dispatch tasks, any node can respond to events, and scaling the system requires only adding nodes — no changes to a central orchestrator needed.
An Architecture Inspired by the Nervous System
Cosmonapse's overall model draws inspiration from biological neural systems, with component names that directly map to this metaphor, making the architecture's logic easier to understand:
- Neuron: Performs a single computation — typically an LLM call, but can be any pure function.
- Axon: Responsible for emitting Signals.
- Dendrite: Responsible for reacting to Signals.
- Synapse: The event bus itself, carrying signal transmission.
- Engram: Provides shared memory storage.
Cosmonapse isn't the first to bring neuroscience concepts into computational architecture. As far back as 1943, McCulloch and Pitts proposed the earliest artificial neural network model using the neuron as its archetype. The word "Engram" was coined by neuroscientist Richard Semon in 1904 to describe the physical trace left by a memory in the nervous system, later studied extensively by Karl Lashley and modern neuroscience. Mapping this concept to shared memory storage precisely captures its "distributed storage, on-demand recall" characteristic. The "Synapse" metaphor for an event bus is equally apt: biological synapses handle signal transmission between neurons and exhibit plasticity, which closely parallels the dynamic routing capability of an event bus. This naming system isn't just an aesthetic choice — it's a cognitive framework that helps developers reason about system behavior using intuitions they already have about the nervous system.
This naming reveals a key design principle: orchestration becomes optional. In Cosmonapse, dispatchers and workers share the same underlying primitive. This means the choice between centralized and decentralized execution is simply a topology decision, not an architectural rewrite. There is no longer a "God Object" accumulating all workflow branches — and this fundamentally changes how multi-agent systems are built.
It's worth noting that Cosmonapse's "peer nodes + event bus" design is closely related to two classic concurrent programming models in computer science. The first is Event-Driven Architecture (EDA), widely used in microservices (e.g., Apache Kafka, AWS EventBridge), where producers publish events and consumers subscribe to respond — with full decoupling between the two. The second is the Actor Model, proposed by Carl Hewitt in 1973 and used in Erlang/Elixir and Akka — where each Actor is an independent unit of computation communicating via message passing, with no shared mutable state. Cosmonapse's "neuron as node, signal as message" paradigm essentially brings the Actor model into LLM agent engineering, while typed signals make up for the observability shortcomings of traditional Actor systems.
The Harness as Product: Turning Everything Into Signals
Cosmonapse's author makes a notable claim: as agent capabilities grow, the Harness (runtime framework) is increasingly becoming the product itself. What makes this framework distinctive is how it decomposes all the concerns traditionally bundled into a monolithic control loop into typed signals.
Tool Calls
Tool use is modeled as TOOL_CALL / TOOL_RESULT signals. Tools can be deployed on any node, and MCP (Model Context Protocol) integrates naturally. MCP is an open protocol introduced by Anthropic in 2024 to standardize how LLMs interact with external tools — providing standardized tool descriptions, invocations, and result formats so that tool ecosystems can be reused across frameworks. In Cosmonapse's signal model, tools are no longer special built-in features of the framework; they're ordinary signal interactions, meaning MCP tools can be plugged in seamlessly just like any other node.
Memory Management
Memory is implemented via hooks: a before-hook recalls state from the Engram and injects it into the prompt, while an output hook "imprints" newly learned content back into memory. The model call itself remains unchanged — memory logic and reasoning logic are fully decoupled. This design allows different memory backends (vector databases, KV stores, graph databases, etc.) to be swapped out transparently without modifying any agent logic.
Human-in-the-Loop
Human-in-the-Loop (HITL) is an important concept in AI safety and reliability, first systematically applied in active learning and RLHF scenarios. In multi-agent systems, HITL poses unique engineering challenges: asynchronous approvals interrupt synchronous control flow, forcing the system to save intermediate state and wait for a human response — something traditional monolithic loops handle poorly.
In Cosmonapse, clarifications and approvals are expressed as signals. An approval gate is simply another node that responds to signals — essentially borrowing from the Saga pattern (the compensating transaction pattern in distributed transactions), treating human decisions as a special kind of "service call" with unpredictable response times but the same interface as any other node. This demotes HITL from an architectural special case to a standard extension point, significantly reducing system complexity.
Control Flow
Control flow is declared per node in the form of "when X's output arrives, dispatch Y" — rather than being embedded in orchestration code. Retries, routing, bidding, and similar mechanisms are all implemented as composable examples, not as proprietary framework features.
Observable, Replayable, and Debuggable
Expressing every step as a typed signal yields an important side effect: the execution process is naturally observable, replayable, and debuggable.
Observability is one of the three pillars of modern cloud-native engineering, alongside monitoring and alerting. In distributed systems, OpenTelemetry has become the de facto standard for distributed tracing, metrics collection, and log aggregation. Its core idea is to express each service call as a Span with a unique ID, timestamp, and context, enabling full reconstruction of execution traces across services. Cosmonapse's approach of expressing each agent step as a typed signal is highly aligned with this philosophy — each signal naturally carries metadata such as type, source, and timestamp, making the entire multi-agent execution process recordable and replayable like a distributed trace.
For developers who have worked on debugging complex multi-agent systems, this is particularly valuable. Due to the non-deterministic nature of LLM outputs, traditional breakpoint debugging is nearly useless, and replay debugging based on signal logs is currently the most practical alternative in the industry — LLMOps tools like LangSmith and Langfuse are exploring similar approaches. In Cosmonapse, the entire Harness "emerges" from interactions between independent nodes. Every signal is typed and logged, making replay and root-cause analysis genuinely feasible.
Open Source and Multi-Language Ecosystem
Cosmonapse is released under the Apache 2.0 license — friendly to commercial use — and provides full multi-language support:
- GitHub: Cosmonapse/cosmonapse-core
- Documentation: cosmonapse.com
- Python:
pip install cosmonapse - TypeScript:
npm i @cosmonapse/sdk
Covering both Python and TypeScript ecosystems, it has a low barrier to entry whether you're a backend engineer or a full-stack developer. The Apache 2.0 license explicitly permits commercial use, modification, and distribution, and includes patent grant protection — making it one of the most enterprise-friendly licenses in today's AI open-source landscape.
A Few Thoughts
Cosmonapse addresses a real pain point in the current agent framework space. At the end of the original post, the author poses a question worth reflecting on for everyone in the field: "As your multi-agent system grows in scale, what's the first thing that becomes unbearable?"
For many, the answer is exactly that increasingly bloated central control loop — the one that couples every responsibility together so that changing one thing breaks everything else. Cosmonapse offers a solution that feels far more natural for distributed systems thinking: peer nodes + event bus + typed signals.
That said, decentralized design is not without its costs. Event-driven architectures tend to impose higher cognitive load — developers need a holistic grasp of message flows, asynchronous state, and topology, which is a significant departure from traditional imperative programming (though signal replayability does mitigate this somewhat). End-to-end testing and deadlock diagnosis in decentralized systems are also more complex than in centralized ones. Whether this will become the dominant paradigm remains to be seen as the community puts it through real-world projects. But at a minimum, it offers a clear and compelling reference point for thinking about how to build the next generation of agent harnesses.
Key Takeaways
Related articles

Should You Open Source Your Project? A Layered Open Source Strategy Using Project Replay as a Case Study
Should indie developers open source their projects? Using the game custom achievement tool Project Replay as a case study, this article analyzes the open source decision and offers a practical layered strategy.

130+ Open-Source Interactive Security Awareness Training: Reshaping Habit Formation Through 3D Office Scenarios
A project with 130+ free open-source interactive security awareness exercises using immersive 3D office scenarios to simulate phishing, vishing, MFA fatigue attacks and more, building employee security habits.

From Musk to Jefferson: Beware the Cognitive Trap of Cross-Domain Experts
Why do geniuses in one field often become overconfident in others? From Musk's controversial interview to Jefferson's blind spots, an exploration of cross-domain cognitive arrogance.