{"slug": "cosmonapse-an-event-driven-protocol-for-ai-agent-systems", "title": "Cosmonapse – an event-driven protocol for AI agent systems", "summary": "Cosmonapse, an event-driven Agent-to-Agent (A2A) protocol with Python and TypeScript SDKs and a developer CLI, models multi-agent systems on a nervous system metaphor where agents are pure functions that emit and react to messages on a shared bus, eliminating the need for a central orchestrator. The protocol supports pluggable transports including in-memory, TCP broker, NATS, and Kafka, and its abstractions—Neuron, Axon, Dendrite, Synapse, Signal, and Engram—enable coordination through message passing rather than hierarchical reporting.", "body_md": "**Event-driven Agent-to-Agent protocol - agents are plain functions, coordination is messages, there is no orchestrator**\n\n[Architecture](#architecture) • [How It Works](#how-it-works) • [Why Cosmonapse](#why-cosmonapse) • [Quick Start](#quick-start) • [Docs](#documentation)\n\nCosmonapse is an event-driven **Agent-to-Agent (A2A) protocol** with a Python SDK, a TypeScript SDK, and a developer CLI (`cosmo`\n\n). It models multi-agent systems on a nervous system instead of a supervisor: agents are pure functions that emit and react to messages on a shared bus, so you grow a system by adding nodes - not by editing a central orchestrator.\n\n[PyPI](https://pypi.org/project/cosmonapse/) · [Envelope Spec](/Cosmonapse/cosmonapse-core/blob/main/design/ENVELOPE_SPEC.md) · [SDK Design](/Cosmonapse/cosmonapse-core/blob/main/design/SDK_DESIGN.md) · [Roadmap](/Cosmonapse/cosmonapse-core/blob/main/design/ROADMAP.md) · [Contributing](/Cosmonapse/cosmonapse-core/blob/main/CONTRIBUTING.md) · [Changelog](/Cosmonapse/cosmonapse-core/blob/main/CHANGELOG.md)\n\n``` python\nimport asyncio\nfrom cosmonapse import Axon, Dendrite, MemoryRegistryStore, connect_synapse\n\nasync def main():\n    synapse = await connect_synapse(\"cosmo://127.0.0.1:7070\")\n    try:\n        async def answerer(input, context):\n            return {\"answer\": input[\"q\"]}\n\n        worker = Dendrite(synapse=synapse, namespace=\"demo\")\n        worker.attach_axon(Axon(neuron_id=\"answerer\", neuron_fn=answerer))\n\n        orch = Dendrite(synapse=synapse, registry_store=MemoryRegistryStore(),\n                        namespace=\"demo\")\n\n        @orch.on_agent_output\n        async def done(sig):\n            await orch.emit_final(trace_id=sig.trace_id, parent_id=sig.id,\n                                  result=sig.payload[\"output\"])\n\n        async with orch, worker:\n            await orch.dispatch_task(neuron=\"answerer\", input={\"q\": \"hi\"})\n            await asyncio.sleep(0.5)\n    finally:\n        await synapse.close()\n\nasyncio.run(main())\n```\n\nCosmonapse maps a multi-agent system onto a neural metaphor. Every layer is a small, replaceable part - there is no central class that has to know about every agent.\n\n| Abstraction | Plays the role of | What it does |\n|---|---|---|\nNeuron |\nThe agent | A pure function `(input, context) -> output` . No base class, no inheritance, no framework lock-in. |\nAxon |\nThe output path | Wraps a Neuron and turns its return value into a protocol-valid Signal. |\nDendrite |\nThe connection point | Attaches Axons to the bus, dispatches work, and reacts to results. Any Dendrite can be a worker, an orchestrator, or both. |\nSynapse |\nThe bus | Transports Signals between Dendrites - in-memory, a local dev TCP broker, NATS, or Kafka. |\nSignal |\nThe message | The typed envelope every agent emits and reacts to (`TASK` , `RESULT` , `CLARIFICATION` , `PERMISSION` , …). |\nEngram |\nShared memory | Durable store so granted permissions and answered questions are recalled instead of re-asked. |\n\nThe key property: coordination happens by passing Signals, not by reporting up to a master orchestrator. Add a fourth agent and you stand up another Dendrite and point it at the Synapse - you do not edit a god object.\n\nThe transport is pluggable because Cosmonapse is a protocol, not a runtime. The same agent code runs across every transport - you change a connection string, not your logic.\n\n| Transport | Best for | Connect |\n|---|---|---|\n| In-memory | Unit tests and single-process apps | `connect_synapse(\"memory://\")` |\n| TCP broker | Local multi-process development | `connect_synapse(\"cosmo://127.0.0.1:7070\")` |\n| NATS | Production, low-latency fan-out | `pip install \"cosmonapse[nats]\"` |\n| Kafka | Production, durable high-throughput streams | `pip install \"cosmonapse[kafka]\"` |\n\n```\n dispatch_task                          emit_final\n      │                                      ▲\n      ▼                                      │\n  ┌─────────┐    TASK     ┌──────────┐    RESULT    ┌─────────┐\n  │ Dendrite│ ──────────▶ │   Axon   │ ──────────▶  │ Dendrite│\n  │ (orch)  │   Synapse   │ (Neuron) │   Synapse    │ (orch)  │\n  └─────────┘             └──────────┘              └─────────┘\n                                │\n                                │  may pause and ask instead of returning\n                                ▼\n                    CLARIFICATION / PERMISSION  ──▶  answered by a peer\n                                                     or a central Cortex,\n                                                     recalled via Engram\n```\n\n- A Dendrite dispatches a\n`TASK`\n\nSignal naming a Neuron and an input. - The Synapse routes it to whichever Dendrite has an Axon for that Neuron.\n- The Axon runs the Neuron and emits the output back as a\n`RESULT`\n\nSignal. - Any Dendrite subscribed to that result reacts - including emitting the final answer.\n- A Neuron can pause and\n*ask*instead of returning: a`__clarification__`\n\nor`__permission__`\n\nmarker becomes a`CLARIFICATION`\n\n/`PERMISSION`\n\nSignal that another Dendrite answers. Human-in-the-loop is just a Signal type, not a bolt-on. - Paired with\n**Engram**, once a question is answered or a permission granted, it is remembered - so agents stop re-asking the same approvals. See§7.5.`design/ENVELOPE_SPEC.md`\n\nA single orchestrator works in the demo. It breaks down when one supervisor has to know every agent, every step, and every branch - it becomes a thousand-line bottleneck every change routes through.\n\nCosmonapse removes the orchestrator and makes responsibilities explicit:\n\n- Agents are pure functions, not subclasses - nothing to inherit, easy to test in isolation\n- Coordination is message-passing on a shared bus, so the system grows sideways instead of onto one chokepoint\n- Human-in-the-loop is a first-class Signal type, not custom plumbing\n- Shared memory (Engram) means granted permissions and answers are recalled, not re-requested\n- The transport is pluggable - the same code runs in-memory for tests and on NATS or Kafka in production\n\n- Define agents as plain Python (or TypeScript) functions and attach them with a single Axon\n- Dispatch and react to work from any node - no central orchestrator class required\n- Run the same code across in-memory, local TCP, NATS, and Kafka transports\n- Pause an agent to request a clarification or permission and have a peer answer it\n- Persist grants and answers in Engram so they are recalled instead of re-asked\n- Drive everything from the\n`cosmo`\n\nCLI - Explore\n[runnable end-to-end examples](/Cosmonapse/cosmonapse-core/blob/main/examples)covering Neurons, providers, Engram, parallel builds, and the orchestrator API\n\nChoose the shortest path that matches how you want to use Cosmonapse.\n\n| Surface | Best for | Start |\n|---|---|---|\n| Python SDK | Building and running agents | `pip install cosmonapse` |\n| TypeScript SDK | Node / browser agents | `npm install @cosmonapse/sdk` |\n| CLI | Terminal-first workflows | one build; `pip install cosmonapse` or `npm i -g @cosmonapse/sdk` |\n\n```\npip install cosmonapse\n```\n\nThis installs both `import cosmonapse`\n\nand the `cosmo`\n\ncommand. Optional extras: `[nats]`\n\n, `[kafka]`\n\n, and `[postgres]`\n\n. To work against a local checkout instead:\n\n```\npip install -e cosmonapse-core/packages/python-sdk\n```\n\nSee [ packages/python-sdk/README.md](/Cosmonapse/cosmonapse-core/blob/main/packages/python-sdk/README.md) for full SDK and CLI documentation.\n\n```\nnpm install @cosmonapse/sdk\n```\n\nThe `cosmo`\n\nCLI has a single implementation, shipped in the Python package -\nthere is exactly one CLI build, so pip and npm users always run identical\ntooling. The npm package includes a `cosmo`\n\nlauncher that installs and runs\nit for you:\n\n```\nnpm install -g @cosmonapse/sdk\ncosmo --help\n```\n\nOn first run the launcher looks for a Python that already has `cosmonapse`\n\ninstalled and delegates to it (`python -m cosmo`\n\n). If none is found, it\nbootstraps automatically: it creates a private environment under\n`~/.cosmonapse/cli-venv`\n\nand pip-installs `cosmonapse`\n\npinned to the npm\npackage's version, so the two stay in lockstep. The only requirement is a\nPython 3.11+ interpreter on PATH (`$COSMO_PYTHON`\n\noverrides discovery). If\nyou already `pip install cosmonapse`\n\n, its own `cosmo`\n\nentry point is the same\ncode and the launcher simply defers to it.\n\nTo work against a local checkout of the SDK:\n\n```\ncd packages/ts-sdk\nnpm install\nnpm run build   # builds dist/index.{js,cjs,d.ts}\n```\n\nSee [ packages/ts-sdk/README.md](/Cosmonapse/cosmonapse-core/blob/main/packages/ts-sdk/README.md) for full SDK documentation.\n\n| Path | Purpose |\n|---|---|\n`packages/python-sdk/` |\nThe `cosmonapse` SDK and bundled `cosmo` CLI |\n`packages/ts-sdk/` |\nTypeScript SDK (+ `cosmo` launcher for npm installs) |\n`packages/prism-ui/` |\nPrism UI |\n`examples/` |\nRunnable end-to-end examples |\n`design/SDK_DESIGN.md` |\nDesign rationale |\n`design/ENVELOPE_SPEC.md` |\nSignal envelope / wire-format spec |\n`design/ENGRAM_DESIGN.md` |\nEngram (shared memory) design |\n`design/ROADMAP.md` |\nRoadmap and milestones |\n`design/DECISIONS.md` |\nArchitecture decision log |\n\n[Python SDK README](/Cosmonapse/cosmonapse-core/blob/main/packages/python-sdk/README.md)- install, quick start, API, CLI[TypeScript SDK README](/Cosmonapse/cosmonapse-core/blob/main/packages/ts-sdk/README.md)- install, quick start, API, CLI[SDK_DESIGN.md](/Cosmonapse/cosmonapse-core/blob/main/design/SDK_DESIGN.md)- design rationale[ENVELOPE_SPEC.md](/Cosmonapse/cosmonapse-core/blob/main/design/ENVELOPE_SPEC.md)- the Signal wire format[ENGRAM_DESIGN.md](/Cosmonapse/cosmonapse-core/blob/main/design/ENGRAM_DESIGN.md)- shared memory design[CONTRIBUTING.md](/Cosmonapse/cosmonapse-core/blob/main/CONTRIBUTING.md)- how to set up and contribute[CHANGELOG.md](/Cosmonapse/cosmonapse-core/blob/main/CHANGELOG.md)- release notes\n\n[Apache 2.0](/Cosmonapse/cosmonapse-core/blob/main/LICENSE) © 2026 Aqib Khan", "url": "https://wpnews.pro/news/cosmonapse-an-event-driven-protocol-for-ai-agent-systems", "canonical_source": "https://github.com/Cosmonapse/cosmonapse-core", "published_at": "2026-07-21 02:35:02+00:00", "updated_at": "2026-07-21 02:52:47.867163+00:00", "lang": "en", "topics": ["ai-agents", "ai-infrastructure", "developer-tools"], "entities": ["Cosmonapse", "Python SDK", "TypeScript SDK", "NATS", "Kafka"], "alternates": {"html": "https://wpnews.pro/news/cosmonapse-an-event-driven-protocol-for-ai-agent-systems", "markdown": "https://wpnews.pro/news/cosmonapse-an-event-driven-protocol-for-ai-agent-systems.md", "text": "https://wpnews.pro/news/cosmonapse-an-event-driven-protocol-for-ai-agent-systems.txt", "jsonld": "https://wpnews.pro/news/cosmonapse-an-event-driven-protocol-for-ai-agent-systems.jsonld"}}