OPEN-SOURCE AGENT PROTOCOL / Multi-Agent Coordination · MIT License

Termite Protocol: Open-Source Engineering Practice for Stateless AI Agent Collaboration

AI coding agents are stateless and ephemeral, yet software projects demand continuity, coordination and memory — and conversation-based multi-agent frameworks are both expensive and fragile. LongArena open-sourced the coordination kernel behind its own production systems as the Termite Protocol: agents never talk to each other; they sense a shared environment. Signals persist in SQLite, tasks are claimed atomically, observations accumulate as pheromone-like memory, and every arriving agent reads a computed .birth snapshot (<=800 tokens) instead of a long protocol manual. Validated across 6 production colonies, 4 multi-model audit experiments and 900+ commits.

LongArena Core Team · · 13 min read ·
Termite ProtocolMulti-AgentStigmergyOpen Source MIT

The Structural Mismatch Between Stateless Agents and Continuous Engineering

Today’s AI coding agents carry a fundamental mismatch: sessions are stateless and disposable, while real software projects need weeks of accumulated context, multi-agent coordination and durable memory. The industry’s common answer is conversational orchestration — agents messaging each other to divide work. But conversation channels are expensive and fragile: context inflates with every turn, role prompts stack up, and when a session dies, the coordination state dies with it.

The Termite Protocol takes the opposite path: move coordination out of the agents’ conversations and into their shared environment. Just as termites never hold meetings yet build monumental nests by sensing pheromone traces (stigmergy), each arriving agent reads an environment snapshot, claims work atomically, and leaves traces behind — order emerges from the environment itself.

This is not a demo toy but the real coordination kernel of LongArena’s production systems: our enterprise products are continuously maintained by multi-agent pipelines whose cross-session memory, atomic task claiming and enforced hand-offs all run on the Termite Protocol. It has been validated across 6 production colonies, 4 multi-model audit experiments and 900+ commits, and is fully open-sourced on GitHub under the MIT license.

Chapter 1: The Protocol Kernel — 10 Grammar Rules, 4 Safety Nets, Caste Permissions

Termite compresses multi-agent collaboration into mechanically enforceable grammar rules instead of relying on agent goodwill. Every agent lifecycle is constrained to a deterministic state machine:

1. Arrive and sense first (ARRIVE -> SENSE -> STATE)

An arriving agent never re-reads long manuals. It senses the environment — BLACKBOARD.md, the .pheromone chain and git status — while field-arrive.sh computes a situational snapshot, then derives its caste and permission boundary (STATE -> CASTE -> PERMISSIONS).

2. Every action leaves a trace (DO -> DEPOSIT)

The protocol forces every action to deposit a traceable signal: code, docs, blackboard records, test results or WIP hand-offs. Low-weight signals evaporate over time (EVAPORATE); high-weight risks must escalate (ESCALATE); repeatedly observed high-quality findings emerge into reusable rules (EMERGE).

3. Over-limit context must molt (MOLT)

When context approaches exhaustion (>80%), the agent must write WIP.md and pheromones, then hand off — a fresh session continues losslessly. This eliminates the reasoning long tail and hallucination drift of marathon sessions. Generated agent entries must carry the protocol seed (SEED), so the collaboration genome propagates.

4. Four non-negotiable safety nets

Commit messages must state what changed and why; protocol and design documents are never deleted; large changes land in small auditable steps; and any agent that spots an ALARM.md signal must stop and read it first. The caste model (soldier / worker / scout / nurse) hard-codes permission boundaries into the protocol layer.

Chapter 2: Four Engineering Mechanisms — the Environment Carries the Intelligence

Conversation-heavy frameworks assume agents must stay context-rich; Termite moves signals, memory and templates into the environment. The runtime is a minimal set of shell scripts plus one SQLite field database:

Termite agent lifecycle: arrive and compute the .birth snapshot, claim and execute atomically, deposit observations and hand off — the next agent continues from the environment. Arrive & sense field-arrive.sh computes .birth Claim & execute field-claim.sh, no double-assignment Deposit & hand off field-deposit.sh writes the field
Termite agent lifecycle: arrive and compute the .birth snapshot, claim and execute atomically, deposit observations and hand off — the next agent continues from the environment.

1. The .birth snapshot: resume work at ~2% context cost

A new session no longer re-reads the ~28K-token protocol document (~40% of the context window). field-arrive.sh computes a .birth snapshot on arrival, compressing blackboard state, active signals and safety hints into <=800 tokens (~2% of context), while conversation-heavy orchestration typically spends 5-15%+ on role prompts and growing chat logs.

2. Atomic signal claiming in SQLite

Tasks persist as signals in a WAL-mode SQLite field database, and claiming happens inside transactions: no scheduler bottleneck, no double-assignment, no conversation overhead. Stalled claims are recovered after heartbeat timeouts, so a hung agent can never squat on a task forever.

3. Pheromone deposition: observations outlive sessions

Observations, decisions and status settle into the repository as a pheromone chain — knowledge survives session death. Memory in long-running projects compounds over time, the essential difference from single-session patterns that restart from zero.

4. Rules emerge from repeated evidence (EMERGE)

When similar observations accumulate enough evidential weight, the system promotes them into reusable rules injected into future .birth snapshots — the environment gets smarter with use, instead of every new agent rediscovering the same pitfalls.

Chapter 3: Proof, Not Hype — the Shepherd Effect

Termite’s most valuable empirical finding is the Shepherd Effect: in a mixed-strength colony, one strong model (the shepherd) leaves high-quality patterns in the field, and weaker workers read the template from .birth and imitate its structure via in-context learning — approaching strong-model output quality at a fraction of the cost. In the touchcli A-005 experiment, 1 Codex shepherd + 2 Haiku workers reached 96.4% observation quality:

Mixed-Model Colony Benchmark (observation / handoff quality)

Subject: real multi-agent audit tasks on the touchcli repository. Observation quality measures the usability of deposited content; handoff quality measures cross-session continuity.

Swipe sideways or use the arrow keys to view all four columns.

ConfigurationObservation QualityHandoff QualityKey Takeaway
2x Haiku working independently (no shepherd)35.7%0%Weak-only execution degrades badly
1x Codex shepherd + 2x Haiku workers96.4%99%Shepherd Effect works: strong patterns are inherited
5-model mixed swarm (max throughput)57%100%Throughput scales, quality needs control

1. Six real colonies, 900+ commits

The protocol has been validated in 6 real colonies: from the first closed audit loop (A-001, 54 commits) to the highest-throughput 5-model swarm (A-006, 562 commits and 113 signals), plus LongArena’s own stable production reference colony — over 900 commits in total.

2. Honest limits: throughput scales, quality needs gates

The experiments also exposed boundaries: a weak-only pair (2x Haiku) degraded to 35.7% observation quality with 0% handoff quality; the 5-model swarm achieved peak throughput but surfaced starvation and dilution. The conclusion is clear — Termite provides the physics of collaboration, but quality gates (a strong shepherd, independent review) remain an engineering necessity.

3. Complementary academic evidence

The 2026 paper SwarmWorld independently studies a closely related direction in controlled simulation: initially homogeneous agents coordinate through a persistent world and accumulate executable artifacts. Termite is the engineering protocol for real repositories and heterogeneous, cross-session coding agents — together they provide complementary evidence for environment-mediated agent coordination.

Chapter 4: Production Practice at LongArena, and Open Source

The Termite Protocol is the foundation of LongArena’s unattended engineering: the Guardian handover gate in our RSI dual-worker pipeline triggers the Session Molt — rule 9 of this very protocol. The BLACKBOARD.md dynamic blackboard, WIP.md cross-session hand-offs and signal-driven incident flow are all direct production instances of protocol mechanisms.

# 60-second smoke test: experience the protocol in a fresh directory
mkdir termite-demo && cd termite-demo
curl -fsSL https://raw.githubusercontent.com/billbai-longarena/Termite-Protocol/main/install.sh | bash
./scripts/field-arrive.sh   # computes the .birth snapshot and bootstraps the colony
./scripts/field-pulse.sh    # project health snapshot: signals=1
sqlite3 .termite.db "select id,status,title from signals;"

1. When to use: parallel agents, mixed-strength models, long-running projects

Multi-agent parallel development (atomic claiming prevents double-assignment), strong+weak model mixes (the Shepherd Effect multiplies weaker models), long-running projects (cross-session memory compounds), large refactors (file-level work parallelizes cleanly), and audit-heavy work (signals and rules stay traceable).

2. When not to use: protocol overhead outweighs one-off gains

Small one-off tasks, open-ended research that needs holistic judgment, and tiny scripts are better served by a single coding agent directly. Being honest about selection boundaries is itself part of the protocol’s culture.

3. Fully open source under MIT: from smoke tests to audit packages

The protocol is fully open-sourced on GitHub under MIT: one command installs and bootstraps a colony, and the smoke test passes in 60 seconds. The repository also ships every experiment audit package (audit-packages/), degeneration-prevention analysis (audit-analysis/) and the knowledge base — reproduction, scrutiny and contributions are all welcome.

Termite Protocol on GitHub (MIT)

Article updated: · demo@long-arena.com