Skip to main content

Token-efficient, verifiable multi-agent AI coordination — passive stigmergic blackboard + minimal per-agent context, with an optional on-chain (ERC-8004 identity + coordination receipts) layer.

Project description

Cairn 🪨

A free AGPLv3 coordination layer that lets multiple AI agents work together without burning the token budget — by coordinating through a passive shared blackboard and minimal per-agent context, instead of conversation. Optionally, it makes that coordination verifiable on-chain.

A cairn is a pile of stones travellers stack to mark a path for those behind — guidance left without speaking. That is Cairn's mechanism: agents leave traces, not messages.


The problem

Multi-agent AI systems fail in production mostly on cost: agents talk to each other in unbounded loops, each carrying the others' full transcripts, until the context — and the bill — explodes. The dominant tooling is reactive (budget caps, circuit-breakers, observability dashboards): it watches the meter and pulls the plug after the fact. It does not change the architecture that generates the spend.

Cairn is preventive — it removes the structure that causes the explosion.

Three mechanisms (each measured in real operation)

  1. Minimal-context workers — each agent loads only a small task-scoped context, not the full project history. Measured: always-loaded context drops ~32K → ~0.8K tokens per agent-turn.
  2. Passive stigmergic blackboard — agents leave short traces (claims, findings, status) in one small shared file and read each other's traces. No agent-to-agent conversation channel. Coordination emerges from a shared filter, not chatter.
  3. Gardener orchestrator — a single supervisor that distills emergent findings and times the close (a resonance valve), intervening only on pathology, never micro-managing.

Measured result (dogfooded, controlled A/B)

On an identical agent task — same model, only the context architecture changed:

naive full-context minimal + blackboard reduction
billable input tokens 488,477 222,680 54%
short-run cost (illustrative) $4.13 $1.44 65%

The throughput / rate-limit win persists even where prompt caching shrinks the dollar delta. The benchmark harness is published so the number is reproducible — and falsifiable — on your own workload.

Quickstart

pip install cairn-coordination          # core — stdlib-only, zero deps   (import name: cairn)
pip install "cairn-coordination[web3]"   # + the on-chain layer (ERC-8004 identity + receipts)

On PyPI (the import name is cairn; cairn was taken).

Framework-agnostic: you supply agent_fn(ctx) and make your own model call inside it. Cairn calls no LLM.

from cairn import run_swarm, Worker, Trace

def agent_fn(ctx):
    # ctx.task = this agent's scope; ctx.board = a compact digest of others' traces (minimal!)
    # call your model, return a Trace — or return None to go idle (self-terminate)
    return Trace(agent=ctx.agent, kind="finding", text="...", value=2.0)

result = run_swarm(agent_fn, [Worker("a", "angle A"), Worker("b", "angle B")])
print(result.closed_reason, result.total_value())

python examples/selftest.py runs an offline, dependency-free demo of the whole loop.

Already on LangChain / CrewAI?

Coordinate your existing framework agents through Cairn's blackboard — minimal per-agent context instead of re-passing the full transcript:

from cairn import run_swarm, Worker
from cairn.adapters import from_langchain   # or: from_crewai, or as_worker_fn for any invoke()

run_swarm(from_langchain(my_chat_model_or_graph),
          [Worker("a", "angle A"), Worker("b", "angle B")])

as_worker_fn(invoke) wraps any invoke(prompt) -> str callable. The adapters import no framework until a wrapped agent runs (pip install "cairn-coordination[langchain]" / [crewai]). Offline demo: python examples/adapter_demo.py.


Verifiable coordination (optional web3 layer)

Token-efficiency commoditizes; verifiability does not. When agents owned by different parties coordinate, they need on-chain identity, receipts, and (optionally) value rails. Cairn adds these as an additive, off-by-default layerimport cairn stays dependency-free, and with no adapter the core runs exactly as before.

from cairn import run_swarm, Worker
from cairn.web3.celo import CeloEVMAdapter

chain = CeloEVMAdapter(private_key=KEY, receipts_addr=RECEIPTS)
run_swarm(agent_fn, workers, receipt=chain)   # emits one verifiable on-chain receipt per run
  • Receipts — one verifiable on-chain record per coordination run (run id + state hash).
  • Identity — each agent gets a verifiable identity via the pre-deployed ERC-8004 registries (identity is config, not a deploy).
  • Payment — optional native-CELO / ERC-20 (cUSD, USDC) transfers between agents.

Live on Celo mainnet (independently verifiable):

Capability Proof
Coordination receipt tx 0xeea84ea9…
Agent identity (ERC-8004) agentId 9211

The chain layer is chain-agnostic by design (a clean adapter interface); Celo/EVM is the first implementation.


Status

The core library (blackboard + minimal-context workers + gardener/valve) and the verifiable-coordination layer are here and working — receipts + identity proven on Celo mainnet, payment on testnet. Funding (NGI Zero Commons / alternatives) is in progress to sustain maintenance.

  • Framework-agnostic — coordinates agents built on LangGraph / CrewAI / a plain script.
  • Composes with cost tooling (LiteLLM, Langfuse) — Cairn lowers the baseline they cap/observe.
  • Sibling of Echo Toolkit — same operator, same commons philosophy, independent projects.

License

AGPLv3. The network-use clause ensures hosted use contributes back. Commercial relicensing available for B2B integrations that cannot accept AGPL — revenue reinvested in maintenance.

Origin

Built by Tağmaç Çankaya (Lefkoşa, Cyprus / EU) out of a felt failure: a full-context headless agent swarm that exhausted its budget almost instantly. Cairn is the rebuild — measured, minimal, and given back.

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

cairn_coordination-0.3.0.tar.gz (35.4 kB view details)

Uploaded Source

Built Distribution

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

cairn_coordination-0.3.0-py3-none-any.whl (34.1 kB view details)

Uploaded Python 3

File details

Details for the file cairn_coordination-0.3.0.tar.gz.

File metadata

  • Download URL: cairn_coordination-0.3.0.tar.gz
  • Upload date:
  • Size: 35.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for cairn_coordination-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0820aca1f0c8b68e0aae96c590f8c2ecc14b59ef6a3fdd45090805b5cf1bb0f6
MD5 03fc01ee295624e382f41ad25294fc66
BLAKE2b-256 3427e32f5f731c86a88a9f8c6324cf1ccb3ee1cac14f54d95f3571e42ecf98aa

See more details on using hashes here.

File details

Details for the file cairn_coordination-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cairn_coordination-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2f4b4ece8fa6ab6d01c3fac644392089a6d68b731f4eef180a6ec3f836a1f00d
MD5 e992e7f39cd2bf57b2bbcebe90e0c4f4
BLAKE2b-256 1b75f68d19b79a31f46e9903510678606bc907ac5b9a7e9daab7982fd0c16e5f

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