Skip to main content

Coordinate parallel AI agent sessions across providers (Claude, DeepSeek, ...) โ€” text-only protocol + Python daemon

Project description

myco

Silent consciousness network for parallel Claude Code sessions.

License: MIT Tests Status Python

๐Ÿ‡ง๐Ÿ‡ท Leia em portuguรชs

myco is a coordination protocol for multiple Claude Code sessions working in parallel. A Python daemon keeps an in-memory index of swarm events and delivers personalized views per session โ€” each session knows in real-time what the others are doing, with no central orchestrator and without the human becoming a messenger.

The analogy is the mycelium: an underground fungal network that connects independent trees, silently transporting signals. Each Claude session remains autonomous in its own project, but shares a bus that myco keeps alive and filtered.

Why

If you use Claude Code (or any agent CLI) intensively, you've probably hit the wall:

  • Long sessions degrade attention. Even with a 1M context window, late-conversation precision drops.
  • One thread can't hold everything. Refactoring the backend while debugging the frontend while reviewing docs = chaos in a single chat.
  • Parallel tabs without coordination are worse. Three agents editing the same repo with no shared awareness produces conflicts, repeated work, and stale assumptions.

myco lets you run N persistent sessions in parallel, each with its own role and clean context, sharing only what matters through a silent bus.

Multi-provider (Claude ร— DeepSeek ร— anything Anthropic-compatible)

The myco protocol is plain text (<myco> block in the response + panel injected in the prompt). Any model that can follow structured instructions can participate, regardless of vendor.

In practice, this works by pointing the Claude Code CLI at any Anthropic-compatible endpoint:

# DeepSeek session in the same swarm
export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="$DEEPSEEK_API_KEY"
export ANTHROPIC_MODEL="deepseek-v4-pro"
./myco DEEPSEEK-IMPL ~/my-project

Validated experimentally across 3 rounds with both sessions writing independent self-evaluations afterwards. Full record (scripts, rubrics, both perspectives) in examples/heterogeneous-swarm/:

  • Round 1 (Spec โ†’ Impl): Claude writes the contract, DeepSeek implements in ~1.5min (7/7 tests). Claude finds an edge case, DeepSeek fixes in ~2min (8/8). Clean round-trip via msg/ + ask + reply.
  • Round 2 (LRUCache, parallel): Technical tie. Both 9/9 green, both OrderedDict + move_to_end, ~32 LOC each. Cross-reviews nearly mirrored.
  • Round 3 (Tetris, parallel): Both 11/11 logic tests green. DeepSeek shipped more polished UX (larger canvas, grid lines, score on game-over). Claude shipped with [hidden] HTML attribute defeated by display: flex in its own CSS โ€” overlay permanently visible. Tests passed; the game didn't.

The deciding axis wasn't capability โ€” it was discipline at non-tested validation. Capability converged (same idioms, same architectures). The CLI session is blind to UI, and that affects whatever model sits behind it.

Practical implications:

  • Cost mix โ€” single Opus architect + several cheap DeepSeek/Groq implementers per round
  • Capability mix โ€” right model per role (design vs bulk code vs review)
  • Resilience โ€” one provider has an outage, the swarm keeps moving
  • No vendor lock-in โ€” the protocol doesn't care who's behind any session

Quickstart

Option A โ€” pip install (daemon + commands on PATH)

pip install myco-swarm

# 1. Generate a tenant token (any 32+ char secret with enough entropy)
export MYCO_TOKEN="myco-$(openssl rand -hex 24)"
export MYCO_URL="http://localhost:8000"

# 2. Run the daemon in one terminal
mycod --port 8000 /tmp/myco-swarm

# 3. In each session terminal, set the hooks manually and launch claude:
#    (the bash launcher in Option B does this automatically)
export MYCO_SESSION=FRONT MYCO_INJECT_VIEW=1
# ... configure .claude/settings.json hooks pointing at `myco-hook` and
#     `myco-prompt-hook` (both installed by pip on your PATH), then run `claude`.

This gives you mycod, myco-view, myco-hook, myco-prompt-hook on the PATH. Use this path if you want to wire myco into your own automation.

Option B โ€” git clone (full launcher with auto-setup)

git clone https://github.com/primoia/myco.git
cd myco

# Run the daemon
python3 prototype/mycod.py --port 8000 /tmp/myco-swarm

# Launch coordinated sessions โ€” the launcher copies CLAUDE.md and
# generates .claude/settings.json with the hooks pointing at the right paths
./myco FRONT  ~/my-frontend-project
./myco BACK   ~/my-backend-project
./myco AUTH   ~/my-auth-project

Each session automatically receives a context panel with every prompt and reports actions via <myco> blocks in its text.

How it works

  1. Sessions log via <myco> blocks โ€” Claude writes a block at the end of each response; a Stop hook captures it and sends it to the daemon
  2. Daemon indexes and renders views โ€” keeps state in memory and generates a personalized markdown view per session
  3. Views are injected automatically โ€” a UserPromptSubmit hook injects the view as additional context on each prompt, with no tool calls
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     <myco> block      โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    view/{S}.md     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Session A  โ”‚ โ”€โ”€โ”€โ”€ Stop hook โ”€โ”€โ”€โ”€โ–ถ  โ”‚  mycod   โ”‚ โ”€โ”€ Prompt hook โ”€โ”€โ–ถ โ”‚  Session B  โ”‚
โ”‚  (Claude)   โ”‚                       โ”‚ (daemon) โ”‚                    โ”‚  (Claude)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                       โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The myco launcher

The myco script in the repo root automates the full session setup:

./myco <SESSION> [project_dir] [--resume] [-- claude_flags...]

# Examples
./myco FRONT ~/my-project              # FRONT session in the my-project repo
./myco FRONT ~/my-project --resume     # resume previous session
./myco FRONT . -- --model sonnet       # extra flags forwarded to claude

What it does:

  • Copies CLAUDE.md (the protocol instructions) into the target project
  • Creates .claude/settings.json with the hooks configured
  • Exports MYCO_SESSION, MYCO_URL, MYCO_INJECT_VIEW
  • Runs claude in the project directory

Protocol

12 verbs for coordination (private is the canonical "private note" verb; log and note are legacy aliases of it):

Verb Meaning
start I started working on X
done I finished X (supports ref:, spec:, result:)
need I declare a dependency on X
block I'm blocked
up a resource came up (supports addr:)
down a resource went down
ask targeted question to another session
reply answer to a question
say broadcast visible to all sessions
direct directive (DIRECTOR-only)
private private note (invisible to others)
log / note legacy aliases of private

key:value conventions: ref:origin/feat/login, spec:msg/AUTH-001.md, ack:msg/CART-001.md, addr:http://host:port, result:ok|fail|partial, re:msg/ID.md

Rich messages: markdown files exchanged via HTTP under msg/, referenced with spec:.

Full details in docs/PROTOCOL.md.

HTTP transport

The daemon exposes an HTTP API for cross-VM use:

Endpoint Method Description
/healthz GET Health check (no auth)
/view/{SESSION} GET Rendered view for the session
/events POST Event ingestion
/msg/{FILE} GET Message read (?session= auto-acks)
/msg/{FILE} POST Message create (immutable, max 64KB)
/status GET JSON state of all sessions

Auth: Bearer token via MYCO_TOKEN (all routes except /healthz).

Security: sanitization of dangerous tags in msg/, message immutability (409 on overwrite), 64KB limit, path-traversal protection.

Documents

Cross-VM setup

# Remote VM
git clone https://github.com/primoia/myco.git
export MYCO_URL=http://<daemon-ip>:8000
export MYCO_TOKEN=your-secret-token
cd myco
./myco FRONT ~/remote-project

The daemon runs on a central machine. Sessions on any VM point MYCO_URL to it.

Status

v1.1 โ€” Stable protocol, validated with real sessions across distributed VMs. 285 unit tests passing.

See CHANGELOG.md for the version history.

Known limitations

  • Session instructions in Portuguese. The launcher copies CLAUDE.md (in Portuguese) into each session's project directory. Sessions read it on every prompt to learn the protocol. An English version of this file is on the roadmap โ€” until then, sessions started by the launcher will operate with Portuguese protocol instructions (which all current LLMs handle fine, but is awkward for non-PT contributors reading the source). Workaround: edit CLAUDE.md after ./myco runs, or maintain your own English copy and point the launcher at it.
  • Hooks are Claude Code specific. The wire protocol (events, views, msg/) is plain HTTP and works with anything. The hook contract (Stop/UserPromptSubmit) is currently Claude Code's. Adapters for Aider, Codex, Continue, etc. are glue work โ€” contributions welcome.
  • Daemon bugs catalogued. A few non-blocking daemon issues are documented in examples/heterogeneous-swarm/evaluations/ (the empty msg/?session= response, duplicate events, pending-messages not clearing on ack). Fixes pending.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

primoia_myco-0.1.0.tar.gz (37.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

primoia_myco-0.1.0-py3-none-any.whl (36.2 kB view details)

Uploaded Python 3

File details

Details for the file primoia_myco-0.1.0.tar.gz.

File metadata

  • Download URL: primoia_myco-0.1.0.tar.gz
  • Upload date:
  • Size: 37.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for primoia_myco-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1145e45c146dbd19f140514bfabd41a97dca36858c713ed7afa79e662799e56b
MD5 e6a6a5e3b815b4ec2ac0d965efb97843
BLAKE2b-256 bad09f7df61c96e68156abccb9c2d2ee9abc8ff435ed91bea598aef3763e0c72

See more details on using hashes here.

File details

Details for the file primoia_myco-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: primoia_myco-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for primoia_myco-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 605cfc528373433ccd4d9aac1482d07cdcc1ae121fa1b372e4be6b15da9703ca
MD5 40178b211dd2747cab3fa2cf33c77278
BLAKE2b-256 3d84876c672c69aaa06f6370f195b36d9bf8eb8a4774ffcc1a1b857adc674596

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page