concepts
Deadlock Prevention
Why Klock never freezes your multi-agent architecture.
A deadlock happens when two or more agents are waiting indefinitely for each other to release resources. If a multi-agent framework deadlocks, the agents will stall, API latency will spike to infinity, and you will burn immense amounts of LLM tokens on spinning loops.
Klock is designed fundamentally to guarantee deadlocks cannot happen.
The Mechanism
As detailed in our Wait-Die Scheduling page, Klock enforces a strict unidirectional waiting topology.
Proof by Contradiction
- Assume a deadlock exists between Agent A and Agent B.
- By definition of a deadlock, Agent A is waiting for Agent B, and Agent B is waiting for Agent A.
- In Klock, Agent A can only wait for Agent B if
Timestamp(A) < Timestamp(B)(i.e., A is older). - For Agent B to also wait for Agent A,
Timestamp(B)must be< Timestamp(A). - Therefore,
Timestamp(A) < Timestamp(B) < Timestamp(A), which is mathematically impossible. - The deadlock cannot exist.
Livelocks and Retries
A livelock occurs when agents aren't frozen, but they continually abort and retry in a way that prevents forward progress (e.g. Agent A aborts, Agent B aborts, they both retry, they collide again).
Klock mitigates livelocks by:
- Guaranteeing queue position for waiting (older) agents.
- Forcing aborted (younger) agents to use randomized exponential backoff before retrying their lease acquisition.
Because of this hardened architecture, you can throw thousands of concurrent agents at a single Klock Kernel, and it will correctly serialize them without ever crashing or stalling your system.