Cellaflow: Step-Level Idempotency and Coordination for AI Agents

Cellaflow uses leases and logs for step-level idempotency, preventing duplicate irreversible operations.
Cellaflow is an open-source project solving AI Agents' duplicate execution of irreversible operations during retries or concurrency. It doesn't require downstream idempotency-key support; instead it wraps tool functions via decorators, with a Rust engine recording results and coordinating concurrency. The core is leases: the first caller executes, later retries or concurrent requests reuse the result. Heartbeats, fencing tokens, and max lifetime prevent split-brain; state persists via append-only log + fsync (RocksDB or Postgres). Compatible with LangGraph, CrewAI, and more; Python/TypeScript SDKs; engine under BSL 1.1, free for production. The community values it but notes added architectural complexity.
AI Agents often run into a thorny problem when automating tasks: repeated execution of irreversible operations. For example, an Agent responsible for placing orders might double-charge on a retry, or two concurrent Workers might grab the same task at once, causing an order to be submitted twice. To address this pain point, the open-source project Cellaflow proposes a solution that doesn't require migrating Agents onto a workflow engine—achieving idempotency and cross-Agent coordination at the step level.

Why Step-Level Idempotency Is Needed
Traditional idempotency mechanisms usually rely on the callee providing an idempotency key, but the reality is that many operations simply don't support this mechanism. In a Reddit post, the author lists typical scenarios: the checkout page you have the Agent click doesn't accept an idempotency key; emails sent via SMTP, calls placed through a telephony provider, and appointments booked through a legacy scheduling system likewise can't guarantee idempotency. Most internal APIs and ERP systems have the same problem.
This means that when an Agent retries due to a timeout or error, the risk of duplicate operations falls entirely on the Agent side. Cellaflow's approach starts precisely from the Agent end: it wraps "irreversible" functions with decorators, and the engine records execution results and handles concurrency.
Idempotency Key is a common means of achieving idempotent operations in distributed systems: the caller generates a unique identifier for each request, the server records the mapping between that key and the result, and when the same key arrives again, it returns the previous result directly without re-executing. Stripe's payment API is a typical example—the client carries an Idempotency-Key in the request header, and the server guarantees that the same key charges at most once. However, the premise of an idempotency key is that the callee actively supports and implements this logic; for legacy systems that can't be modified, clicks on third-party pages, SMTP emails, and similar scenarios, the caller has no right to demand that the other party recognize an idempotency key. Cellaflow's value lies in shifting idempotency responsibility from the callee to the Agent side, with the engine intercepting duplicate requests before the call even happens, thereby bypassing the limitation that downstream systems don't support idempotency keys.
How It Works: Leases and Result Reuse
Cellaflow's core mechanism revolves around "leases." When an Agent calls a function decorated with @tool, the first caller obtains the lease and performs the operation, and the engine records the result. Subsequent retries, or another Agent requesting the same operation, receive the previous result directly without executing again.
The author tested this on an open-source Agent codebase, counting duplicate executions by killing processes midway and running multiple Workers concurrently. Taking Skyvern as an example, when two Workers handle the same checkout task simultaneously, they would originally each place an order; with leases and operation-level idempotency added, the second Worker is rejected and the order is submitted only once.
The engine itself is a Rust daemon that communicates via gRPC and uses RocksDB or Postgres for storage. Each session runs in its own actor (a Tokio task with a mailbox), and session state is not shared between actors. Before the engine responds, operations are written to an append-only log and fsynced to ensure durability. When a session is idle, the actor is evicted and rebuilt from the log on the next request—the same process is also used for crash recovery.
Append-Only Log is a persistent data structure in which all state changes are written as appended records rather than modified in place. Combined with the fsync system call to force data to disk, it guarantees that confirmed operations won't be lost even if power fails immediately after a write. Cellaflow writes the log and fsyncs before responding to the caller, meaning that the fact that "the operation has executed" is persisted before the result is returned, and results can be rebuilt from the log on retry. This design also makes crash recovery simple: after a restart, replaying the log restores session state without relying on volatile in-memory data. Both RocksDB and Postgres support this append-write pattern—the former is suited to high-throughput single-node scenarios, while the latter facilitates shared storage across multiple nodes.
Lease Management: Heartbeats, Fencing Tokens, and Timeouts
An expired lease doesn't necessarily mean the holder is dead—it might just be slow. To distinguish between these two cases, Cellaflow requires holders to send heartbeats and assigns each lease a fencing token. If an old holder wakes up after another Worker has taken over, the engine rejects its commit, thereby avoiding split-brain problems.
In addition, the engine sets a maximum lease lifetime, one hour by default, to handle Workers that hang without exiting the process. Other callers wait for the current holder to finish and receive its result; if the holder never finishes, one of the waiters can take over.
For cross-session coordination, Agents in different sessions can share the same operation by passing the same coordination ID.
Fencing Token originates from the classic distributed-systems solution for preventing split-brain: each time a lease is granted, the token increases monotonically, and the holder must carry that token when committing an operation. The storage layer or engine rejects commits whose token is smaller than the currently known maximum, because that means the holder has expired and the resource has been taken over by a new holder. Even if an old holder "revives" due to a GC pause or network partition, its commit will fail because the token is stale, thereby avoiding data corruption from two Workers writing simultaneously. The heartbeat mechanism is used to distinguish "the holder is dead" from "the holder is just slow": the holder renews periodically, and the engine allows other callers to take over only after the heartbeat times out, reducing frequent handovers caused by misjudgment.
Quick Start and Ecosystem Support
Using Cellaflow takes only three steps: start the engine, install the SDK, and wrap your tool functions. Here's a simple Python example:
from cellaflow import workflow, tool, IdempotencyScope
@tool(
tool_name="charge_card",
scope=IdempotencyScope.SCOPE_SHARED,
shared_on=["order_id"],
)
def charge_card(order_id: str, amount_cents: int) -> dict:
return payments.charge(order_id, amount_cents)
@workflow(version="1.0.0")
def checkout(order_id: str) -> dict:
return charge_card(order_id, 2499)
Two calls to checkout("order-88", _coordination_id="order-88") use the same coordination ID, guaranteeing the charge is executed only once.
Cellaflow claims compatibility with all major Agent frameworks, including LangGraph, CrewAI, AutoGen, and the OpenAI SDK. The SDK is available in Python and TypeScript and is licensed under Apache 2.0 or MIT; the engine uses the BSL 1.1 license, allowing free production use, and will convert to Apache 2.0 on a fixed date.
BSL 1.1 (Business Source License 1.1) is a "delayed open-source" license: it allows users to use, modify, and distribute the software for free, even in production, but restricts offering the software as a hosted service (i.e., competing with the license holder). The license specifies a "change date," after which it automatically converts to a fully open-source license (such as Apache 2.0). Cellaflow's engine uses BSL 1.1, meaning teams can deploy it in production for their own use for free, but if they want to build and sell a hosted idempotency service based on it, they need a commercial license. This model is fairly common among infrastructure open-source projects (such as some HashiCorp products), balancing community adoption with commercial sustainability.
Community Feedback and Potential Considerations
After the project was posted on Reddit, it sparked discussion about Agent reliability. Some developers believe that step-level idempotency is an essential capability for building production-grade Agents, especially when it comes to side-effect operations such as payments and communications. Others pointed out that introducing a separate engine adds architectural complexity, and the reliability benefits need to be weighed against it.
From a design perspective, Cellaflow uses logs and leases to provide a general-purpose idempotency layer on the Agent side without requiring downstream systems to be modified. This is especially valuable for legacy systems that can't be changed. However, its actual performance, latency under high concurrency, and long-term maintenance sustainability still await validation through more production cases.
For teams building multi-Agent collaboration or needing reliable retry mechanisms, Cellaflow offers an open-source option worth watching. The project provides quick-start documentation and an online demo, so developers can experience crash recovery and concurrent coordination for themselves.
One-line Summary
Cellaflow achieves step-level idempotency on the Agent side using leases and logs, avoiding repeated execution of irreversible operations.
Paragraph Summary
Cellaflow is an open-source project aimed at solving the problem of AI Agents repeatedly executing irreversible operations during retries or concurrency. It doesn't require downstream systems to support idempotency keys; instead, it wraps tool functions on the Agent side via decorators, and a Rust engine records execution results and coordinates concurrency. The core mechanism is the lease: the first caller obtains the lease and executes, while subsequent retries or concurrent requests reuse the result directly. The engine uses heartbeats, fencing tokens, and a maximum lifetime to distinguish a dead holder from a slow one, preventing split-brain. State is persisted via an append-only log with fsync, backed by RocksDB or Postgres. The project is compatible with major frameworks like LangGraph and CrewAI, offers Python and TypeScript SDKs, and the engine uses the BSL 1.1 license, allowing free production use. The community recognizes its value but also notes that introducing a separate engine adds architectural complexity.
Related articles

Prompt Engineering for Beginners: From Writing Prompts to Engineering Thinking
Starting from the essence and four functions of prompts, this article systematically explains the six-step process, four success criteria, learning value, and practical limitations of prompt engineering to help you build a complete understanding.

Anthropic Launches Nasdaq IPO: AI Giant's Listing and Risk Disclosures
Anthropic officially launches its Nasdaq IPO under ticker ANT, with market valuation expected to potentially exceed SpaceX's record. The prospectus devotes nearly 100 pages to AI risks, while first-half revenue grew over 14x but net losses widened sharply, reigniting the AI bubble debate.

Rust cURL Clone Uses 4,832 unsafe Blocks—Is the Memory Safety Myth Broken?
A Rust cURL clone uses 4,832 unsafe keywords, challenging Rust's memory safety narrative. We analyze what unsafe really means, compare Fil-C, and examine rewrite motives.