Klock Protocol v1.0

The Mutex for the Agent Economy

When LangChain or CrewAI agents race to modify the same files, they corrupt each other's work—silently. Klock is the coordination kernel that stops it.

pip install klock-langchain

The Problem

The Multi-Agent
Race Condition

When two AI agents modify the same file, the last one to save wins— and your code breaks. We call this the Multi-Agent Race Condition (MARC).

MARC is worse than ordinary data races because the build still passes. You get syntactically valid but semantically incomplete code—with no error signal.

24%
of intended code changes silently lost in our real-world study with 5 Claude Code agents on a shared Express codebase.Build status: passing.

Common Failure Modes

Lost Updates

Agent A's changes overwritten by Agent B. Silent data loss.

Duplicate Artifacts

Rename/move operations conflict, causing repository corruption.

Livelock

Retry storms under contention. 0% forward progress.

Corrupted State

Interleaved partial writes cause build/deploy failures.

Research Results

Proven in the Lab
and in the Wild

Klock achieves near-pessimistic safety while preserving parallelism. These are real numbers from our research paper and implementation.

Simulation: 5 Agents, 70% Contention+ dynamic scope
ProtocolSuccessAbortRetries
Pessimistic100%0%0.0
Klock
100%0%1.7
Optimistic84.8%15.2%3.1
Chaos16.4%83.6%
Real-World: 5 Claude Code AgentsExpress codebase
MetricSolo baselineConcurrentLoss
Lines changed3,0272,311−716
Auth routes
100%0%100% lost
Validation schemas12 of 121 of 12−92%
Build status Pass Pass
The build passed. No error signal. 24% of work silently lost.
This is why Klock exists.

The Klock Protocol

Three Steps to
Safe Concurrency

STEP 01

Declare Intent

Before touching any file, agents declare what they intend to modify. Klock's conflict matrix detects collisions in O(1).

ACQUIRE /src/auth.ts [WRITE]
STEP 02

Acquire Lease

Klock grants an exclusive time-bounded lease using Wait-Die scheduling. Deadlocks are mathematically impossible.

VERDICT: GRANTED (lease_id: a4f2)
STEP 03

Execute Safely

The agent works within its declared scope. On completion, the lease releases and waiting agents proceed.

RELEASE a4f2 → next agent unblocked

One decorator. Full protection.

The @klock_protected decorator wraps any LangChain tool with Wait-Die concurrency control. No architecture changes required.

tools.py
# klock-langchain integration
from klock_langchain import klock_protected
from langchain_core.tools import BaseTool

# Wrap any tool with Wait-Die control
class WriteFileTool(BaseTool):
    name = "write_file"

    @klock_protected(
        resources=["./src/**/*.ts"],
        agent_id="refactor-bot-01",
        priority=100
    )
    def _run(self, path, content):
        # Exclusive lease guaranteed
        write(path, content)

Pricing

Free to start.
Enterprise-ready.

Open source the client, monetize the cluster. Get addicted to import klock—then let us run it in production.

Open Source · MIT
Free

Local kernel, full SDK access. No credit card required. Perfect for solo developers.

Start building
klock-core — local coordination kernel
npm install @klock-protocol/core
pip install klock-core
klock-langchain, klock-crewai adapters
CLI: intent sniffer, conflict detector
Single-node, unlimited agents
Enterprise
Custom

Hosted coordination layer for distributed swarms. Centralized monitoring and high availability.

Talk to Sales
Klock Cluster — high-availability
Black Box Recorder & Replay
Policy Engine — RBAC for agents
SOC2/HIPAA compliance support
SSO / enterprise authentication
Priority support + SLA

Integrations

Works where you work.

Drop Klock into any agent framework with a single decorator. No architecture overhaul required.

LangChain
klock-langchain
Available
LangGraph
klock-langgraph
Available
CrewAI
klock-crewai
Coming soon
AutoGPT
klock-autogpt
Coming soon
OpenDevin
klock-opendevin
Planned
Native Rust
cargo add klock-core
Available

Ready to stop agent collisions?

Install the open-source kernel in 30 seconds. Coordinate your first multi-agent system today.