大家好,我是 Aqib,来自美国,是 Cosmonapse 的开发者。我本人不懂中文,下面这篇介绍是借助 AI 翻译成中文的,如有翻译错误或表达不够自然的地方,还请大家多多包涵。英文原文附在文末,供需要的朋友对照参考。
软件名称
Cosmonapse
应用平台
Windows / macOS / Linux(Python 库与命令行工具;另有云端版本正在内测)
推荐类型
〖开发者自荐〗
一句简介
在事件总线上构建多智能体 AI 系统的开源 Python 平台,不用画图,也不用写循环。
应用简介
开源仓库:GitHub | 安装:
pip install cosmonapse| 官网:cosmonapse.com | 许可证:Apache 2.0
现在大多数 AI 智能体框架,第一步都是让你先画一张图:节点、边、分支,中间再放一个 supervisor 负责推着流程转。系统小的时候这样没什么问题。可一旦事情复杂起来,比如某个工具调用迟迟不返回、人在中途插了一手、第二个模型和第一个模型意见不合,你就会发现自己维护的早已不是业务逻辑,而是一台比问题本身还要庞大的状态机。
Cosmonapse 换了一条路。它把多智能体系统当作一套神经系统来建模:各个组件向一条共享总线发出 Signal(信号),同时对总线上的 Signal 做出反应。没有谁站在中间握着一个循环。想让系统长大,就往上加一个节点,而不是去改中央控制器
这张图就是核心思路。左边是传统的调用栈模型:一个调用方,一个被调用方,一条返回路径。编排器调用智能体,智能体调用工具,而在工具执行期间,整条链路都是"聋"的。右边是事件总线:发出一次,谁关心谁就去听。在调用栈里无处安放的迟到回复,到了总线上不过就是又一个 Signal。
它是什么
Cosmonapse 是一套 Python 平台,由三部分组成:
Core:开放协议、Python SDK 和 cosmo 命令行工具。这是整个项目的根基,可以独立使用,并且会永远保持免费开源。
Genesis:可视化设计器。你在画布上摆放组件,它通过 AST 级别的编辑把真正的 Python 模块写进你的项目里。这不是一次性的生成代码,而是直接修改你自己的文件,注释和格式都会保留。
Prism:可观测性平面。一条 Signal 流,五种视图:实时图、每次运行的执行图、因果树、原始记录,以及指标。
三者唯一共享的东西是 Signal 的信封格式。Genesis 往总线上写,Prism 从总线上读,而 Core 就是总线本身。谁都不"拥有"这个系统,正因为如此,设计器和可观测工具才能在互不依赖的前提下,描述同一个正在运行的程序。
为什么不用图
图框架把控制流编码成拓扑结构,也就是把时间变成了空间。但真实系统是并发的,而且只是部分有序。当你需要处理扇出、重试和取消时,图框架会要求你把这些也画成分支,于是你维护的状态机只会越长越大。
Cosmonapse 把并发、扇出、重试和排序放进传输层,这正是分布式系统二十年来的做法,而不是让你提前画好分支。
一个 TASK Signal 发出去之后,worker 们抢着认领,竞价者相互竞争,能力匹配自动介入,critic 审查输出,合规节点标记高风险调用,这一切都是自动发生的。想增加一个响应者,启动一个进程就行,不需要改动调用方的结构。
八个基本概念,个个似曾相识
如果你写过从消息队列里消费消息的服务,这里的每个概念你其实都已经懂了,只是换了个名字:
| Cosmonapse | 通俗说法 |
|---|---|
| Signal | 总线上的一条消息 |
| Synapse | 总线本身:内存、本地 TCP、NATS 或 Kafka |
| Neuron | 一个智能体:接收输入、返回输出的异步函数 |
| Axon | 包在 Neuron 外面的注册信息:它的 ID 和能力声明 |
| Dendrite | 你的进程所运行的总线客户端:负责连接、注册、监听、派发 |
| Engram | 共享存储,通过总线访问,而不是当作库来 import |
| Effector | 工具,或者任何副作用 |
| Receptor | 你的入口:命令行、HTTP 路由、聊天界面 |
不用配置调度器,不用声明图,也不用继承任何基类。
代码长什么样
最简单的情况下,一个 Neuron 就是一个普通的异步函数。它接收输入、返回输出,仅此一点就已经是一个完整的智能体了:
python
async def answerer(input, ctx):
return {"answer": input["q"]}
# 没有基类,没有生命周期钩子,函数里没有任何框架代码
框架并不关心这个函数内部发生了什么,它只关心一个 TASK Signal 进去、一个结果出来。所以这个函数可以像上面那样简单,也可以把一个大得多的东西包在里面。
它可以是一个大语言模型。SDK 自带了托管模型和本地模型的工厂方法,一行调用就能把一个现成的聊天模型变成 Neuron:
python
from cosmonapse import Axon
AXON = Axon.openai(
neuron_id="writer",
model="gpt-4o",
capabilities=["draft"],
)
# Axon.anthropic()、Axon.huggingface()、Axon.ollama() 和 Axon.mcp() 用法相同
它也可以是另一整套 AI 系统。如果你手头已经有一个用其他框架写好的智能体,不需要重写,把它放到一个函数后面就行。比如一个编译好的 LangGraph 图,对 Neuron 来说只是一个被调用的对象:
python
from my_langgraph_app import graph # 一个编译好的 LangGraph StateGraph
async def researcher(input, ctx):
state = await graph.ainvoke({"question": input["q"]})
return {"answer": state["final_answer"]}
在总线看来,这三者没有任何区别:都通过 Axon 注册,都接收 TASK Signal,都发出结果。一个手写函数、一个大语言模型和一个完整的基于图的智能体,可以坐在同一条总线上互相传递工作,彼此都不需要知道对方是用什么做的。这正是重点所在:组合的基本单位是 Signal,而不是智能体的内部实现。
工具、记忆、审批和重试都以钩子和带类型的 Signal 的形式,围绕这个函数进行组合。模型调用本身保持原样。你可以在零基础设施的情况下做单元测试,也可以随意更换模型。
上手步骤:
bash
pip install cosmonapse
cosmo init my-app -n demo
cd my-app
python brain.py
cosmo init 生成的是一个可以直接运行的项目,而不是 hello-world:brain.py(入口)、neurons/(智能体)、effector/(工具)、engram/(记忆)、receptors/(接口)。运行 python brain.py 会启动所有节点,并进入一个 REPL。
要跑在真正的消息中间件上:
bash
cosmo synapse start memory --namespace=demo
SYNAPSE_URL=cosmo://127.0.0.1:7070 python brain.py
从内存到 TCP,再到 NATS、Kafka,扩展只需要换一个 URL。
编排器是可选的
大多数框架把编排器当作系统的中心。在 Cosmonapse 里,编排只是一种角色。你可以运行一个派发器,也可以运行好几个,或者干脆一个都不要。派发器就是一个碰巧负责派发的普通节点,和其他节点用的是同一套基本概念,不需要改任何代码。系统是横向生长的,而不是全都堆到一个瓶颈上。
取消与回放
有两件事在图框架里极难做到,而在事件模型里却是水到渠成。
取消是一条消息,而不是一个标志位。一个 STOP Signal 沿着 trace-id 广播出去,每个参与者各自确认自己已经停止:智能体 A 取消进行中的工作,智能体 B 通过 saga 日志回滚写入,工具放弃调用并释放资源。你是确切地知道它停了,而不是希望它停了。
回放就是重新发出。整个运行过程就是一份事件日志,通过 trace-id 和 parent-id 关联起来。事后分析变成了查询,失败变成了测试用例。fork 一份日志,就能跑 what-if 场景。
关于这个项目
Cosmonapse 目前的版本是 v0.1.12,处于研究预览阶段。Core、Genesis 和 Prism 全部打包在 pip install cosmonapse 里,不需要额外下载任何东西。许可证是 Apache 2.0,核心部分永远不会设置付费墙。
此外还有一个云端应用,目前正在内测。它建立在本文所述的同一套理念和同一份开源代码之上:托管的 Synapse 和工作区,Genesis 与 Prism 从云端提供,团队不用自己搭建基础设施就能跑同一条总线。本地的开源版本并不是云端产品的演示版,它本身就是产品,云端只是运行它的一种方式。
这个项目非常欢迎贡献。无论是提 issue、交 PR、改进文档还是编写示例,都非常欢迎。如果你对事件驱动的 AI 系统感兴趣,欢迎加入。
如果你用 SDK 搭出了有意思的拓扑结构,可以把演示视频和仓库链接发到 [email protected],我们会在官网上展示。这里有一个例子:YouTube 演示
相关链接:
- GitHub:github.com/Cosmonapse/cosmonapse-core
- PyPI:pypi.org/project/cosmonapse
- 示例:github.com/Cosmonapse/cosmonapse-examples
- 官网:cosmonapse.com
------ Original English text ------
Cosmonapse - Build multi-agent AI systems on an event bus, no graphs, no loops
Open source: GitHub | Install:
pip install cosmonapse| Website: cosmonapse.com | License: Apache 2.0
Most AI agent frameworks today ask you to draw a graph first. Nodes, edges, branches, a supervisor in the middle turning the crank. That works fine when the system is small. But as soon as things get complicated - a tool call takes too long to return, a human interrupts halfway through, a second model disagrees with the first - you realize you’re no longer maintaining business logic. You’re maintaining a state machine bigger than the problem itself.
Cosmonapse takes a different approach. It models a multi-agent system like a nervous system: components emit Signals onto a shared bus, and react to Signals from that bus. Nobody sits in the middle holding a loop. You grow the system by adding a node, not by editing a central controller.
This diagram captures the core idea. On the left is the traditional call-stack model: one caller, one callee, one return path. The orchestrator calls the agent, the agent calls the tool, and while the tool is executing the entire chain is deaf. On the right is the event bus: emit once, anyone who cares can listen. A late reply that has nowhere to go in a call stack is just another Signal on the bus.
What it is
Cosmonapse is a Python platform suite with three parts:
Core - the open protocol, the Python SDK, and the cosmo CLI. This is the foundation. It stands on its own and will always be free and open source.
Genesis - a visual designer. You place components on a canvas, and it writes real Python modules into your project through AST-level edits. Not throwaway generated code - it modifies your actual files, preserving comments and formatting.
Prism - the observability plane. One Signal stream, five views: a live graph, an execution graph for each run, the causal tree, raw records, and metrics.
The only thing they share is the Signal envelope format. Genesis writes onto the bus, Prism reads from the bus, and Core is the bus. None of them owns the system, which is exactly why a designer and an observability tool can describe the same running program without depending on each other.
Why not graphs
Graph frameworks encode control flow as topology. They turn time into space. But real systems are concurrent and only partially ordered. When you need to handle fan-out, retries, and cancellation, graph frameworks make you draw those as branches too - so the state machine you’re maintaining keeps growing.
Cosmonapse puts concurrency, fan-out, retries, and ordering in the transport layer - the same approach distributed systems have used for twenty years - instead of branches you draw in advance.
When a TASK Signal goes out, workers race to claim it, bidders compete, capability matching kicks in, a critic reviews the output, compliance flags risky calls - all automatically. Adding a responder means starting a process, not restructuring the caller.
Eight primitives, all familiar
If you’ve ever written a service that consumes messages from a queue, you already know every concept here. The labels are just different:
| Cosmonapse | Plain terms |
|---|---|
| Signal | a message on a bus |
| Synapse | the bus itself - in-memory, local TCP, NATS, or Kafka |
| Neuron | an agent: an async function that takes input and returns output |
| Axon | the registration around a Neuron - its ID and capability declarations |
| Dendrite | the bus client your process runs - connects, registers, listens, dispatches |
| Engram | shared storage, accessed over the bus instead of imported as a library |
| Effector | a tool, or any side effect |
| Receptor | your entry point - a CLI, an HTTP route, a chat interface |
No scheduler to configure. No graph to declare. No base class to inherit from.
What the code looks like
At minimum, a Neuron is a plain async function. It takes an input and returns an output, and that alone is a complete agent:
python
async def answerer(input, ctx):
return {"answer": input["q"]}
# no base class, no lifecycle hooks, no framework code inside
The framework does not care what happens inside that function. It only cares that a TASK Signal goes in and a result comes out. So the function can be as simple as the one above, or it can wrap something much bigger.
It can be an LLM. The SDK ships factories for hosted and local models, so a stock chat model becomes a Neuron in one call:
python
from cosmonapse import Axon
AXON = Axon.openai(
neuron_id="writer",
model="gpt-4o",
capabilities=["draft"],
)
# Axon.anthropic(), Axon.huggingface(), Axon.ollama() and Axon.mcp() work the same way
It can be another AI system entirely. If you already have an agent built on some other framework, you do not rewrite it. You put it behind a function. A compiled LangGraph graph, for example, is just something the Neuron calls:
python
from my_langgraph_app import graph # a compiled LangGraph StateGraph
async def researcher(input, ctx):
state = await graph.ainvoke({"question": input["q"]})
return {"answer": state["final_answer"]}
To the bus, all three of these look identical. They register with an Axon, they receive TASK Signals, they emit results. A hand-written function, an LLM, and a whole graph-based agent can sit on the same bus and hand work to each other without knowing what the other one is made of. That is the point: the unit of composition is the Signal, not the agent’s internals.
Tools, memory, approvals, and retries compose around the function as hooks and typed Signals. The model call itself stays stock. You can unit-test with zero infrastructure and swap models freely.
Getting started:
bash
pip install cosmonapse
cosmo init my-app -n demo
cd my-app
python brain.py
cosmo init generates a working project, not a hello-world: brain.py (entry point), neurons/ (agents), effector/ (tools), engram/ (memory), receptors/ (interfaces). python brain.py starts all nodes and drops you into a REPL.
To run on a real broker:
bash
cosmo synapse start memory --namespace=demo
SYNAPSE_URL=cosmo://127.0.0.1:7070 python brain.py
Scaling from in-memory to TCP to NATS to Kafka is just changing a URL.
The orchestrator is optional
Most frameworks treat the orchestrator as the center of the system. In Cosmonapse, orchestration is just a role. You can run one dispatcher, several, or none at all. A dispatcher is just a regular node that happens to dispatch - same primitive as every other node, zero code changes. The system grows sideways, not onto a single bottleneck.
Cancellation and replay
Two things that are extremely hard to do in graph frameworks come naturally in an event model.
Cancellation is a message, not a flag. A STOP Signal broadcasts on the trace-id, and each participant independently confirms that it stopped - agent A cancels in-flight work, agent B rolls back writes through a saga journal, the tool abandons its call and releases resources. You know it stopped, rather than hoping it stopped.
Replay is just re-emission. The entire run is an event log, correlated by trace-id and parent-id. Post-mortems become queries. Failures become test fixtures. Fork a log and run what-if scenarios.
About the project
Cosmonapse is currently at v0.1.12, in research preview. Core, Genesis, and Prism all come bundled in pip install cosmonapse - nothing extra to download. The license is Apache 2.0, and the core will never be paywalled.
There is also a cloud app, currently in beta testing. It is built on the same thesis and the same open source code described here: hosted Synapse and workspaces, with Genesis and Prism served from the cloud, so a team can run the same bus without standing up infrastructure. The local, open source version is not a demo of the cloud product. It is the product, and the cloud is one way to run it.
The project is very open to contributions. Whether it’s filing issues, submitting PRs, improving docs, or writing examples - all contributions are welcome. If event-driven AI systems interest you, come get involved.
If you build a creative topology using the SDK, send a demo video and your repo link to [email protected] and it’ll be showcased on the website. Here’s an example: YouTube demo
Links:
- GitHub: github.com/Cosmonapse/cosmonapse-core
- PyPI: pypi.org/project/cosmonapse
- Examples: github.com/Cosmonapse/cosmonapse-examples
- Website: cosmonapse.com





