How GitLab runs a stateless LangGraph agent on a custom checkpointer
GitLab Duo's agent service, the Duo Workflow Service behind GitLab Duo Agent Platform, writes every LangGraph checkpoint into GitLab's own Postgres, yet the service has no connection to that database. Each checkpoint read and write travels down the user's own gRPC stream. The client (an IDE, the CLI or Workhorse) makes the HTTP call to GitLab and hands back the answer.
A LangGraph agent service can keep nothing about a session between requests if a custom LangGraph checkpointer writes into the database the product already has. Inside a request, it still holds the whole run in memory.
The Duo Workflow Service (DWS) pays for this with a second copy of LangGraph's persistence layer. That price is right for GitLab. For most teams it is wrong, for the reason in the last section.
On 2026-11-21 I measured 60 big-company public repos for LangGraph depth. Of the 18 deep users, GitLab's ai-assist ranked second, with 56 production files importing LangGraph and 61 checked-in graphs. Five of the 18 run their product on a saver they wrote, and only GitLab relays checkpoint writes through the client.
Everything I say about DWS comes from reading ai-assist's main branch as of 2026-11-23. I did not run DWS, did not call GitLab's API, and measured no latency.
How the stateless LangGraph agent rebuilds each run from its checkpointer
Each gRPC request is one stream, one run, and one astream call. A session spans several requests, one per turn or resume. Every request compiles the graph again. Compiling is CPU-bound, so it runs in a thread, as GitLab's code comment explains:
compiled_graph = await asyncio.to_thread(
self._compile, goal, tools_registry, checkpointer
)
Excerpt from GitLab's ai-assist, GitLab Enterprise Edition licence (LICENSE); abstract_workflow.py L1207-L1212.
The saver the graph is compiled around is also new for each request:
async with GitLabWorkflow(
self._http_client,
self._workflow_id,
self._workflow_type,
self._workflow_config,
gitlab_status_update_callback=on_gitlab_status_update,
) as checkpointer:
Excerpt from GitLab's ai-assist, GitLab Enterprise Edition licence (LICENSE); abstract_workflow.py L1130-L1136.
One GraphQL read returns the session's Rails status along with its first and latest checkpoints. In the common case, the saver's aget_tuple decodes that latest checkpoint without another HTTP call. The one read a stateless service must pay is folded into a session read it makes anyway.
The status then decides the entry:
- created starts the run;
- a waiting status resumes it;
- finished is an error;
- stopped triggers stop recovery;
- anything else, including a session still marked running, retries from the last checkpoint.
A pause runs like this. A tool-approval node calls interrupt, the saver posts the interrupt write, and the stream ends. At that point nothing about the paused run is left in the process.
The next request recompiles the graph and feeds it Command(resume=event, update=state_update or None). As far as I can tell from the code, nothing ties that resume to the same process. That is an inference, because I did not read the load-balancer configuration.
GitLab's design doc (n.d.) says it plainly: "The Workflow service will not have any persisted state but the state of running workflows will be kept in memory and periodically checkpointed in GitLab." The second clause matters. DWS holds the run in memory for the life of the stream, and its RunInbox is "never stored".
Where GitLab's LangGraph checkpointer stores state: Postgres, via the client
ExecutorGitLabHttpClient turns each call into a RunHTTPRequest action on the user's stream. The saver's docstring names the consequence: "Every Rails call here is relayed by the executor, which is the client and may never answer." GitLab's runbook (n.d.) says where the data lands: "They are stored in the Postgres DB."
async for type, state in compiled_graph.astream(
input=invocation.graph_input,
config=graph_config,
stream_mode=["values", "messages", "updates"],
durability=self._checkpoint_durability(),
**invocation.context_kwargs,
Excerpt from GitLab's ai-assist, GitLab Enterprise Edition licence (LICENSE); abstract_workflow.py L1227-L1232.
Only one flow, the single entry on an allowlist, runs with "sync" durability. Every other flow uses LangGraph's default "async". LangChain's docs (n.d.) say that mode carries "a small risk that LangGraph does not write checkpoints if the process crashes during execution."
Each save gets a 60-second timeout per attempt and "4 attempts with 3s / 9s / 27s of backoff between them". My reading of LangGraph's loop, which I have not tested, is that async saves are chained. One slow save then delays the next.
When the client stream closes, the workflow task is cancelled.
With no client, nothing gets saved.
A minimal custom BaseCheckpointSaver: three methods resume an interrupt
The docs (n.d.) say a custom BaseCheckpointSaver needs five methods: "All are required." I expected the minimum to be the full set.
It isn't. I ran a reduction on GitLab's locked versions: langgraph 1.2.14, langgraph-checkpoint 4.3.1, langchain-core 1.7.7, on Python 3.12.13. A synchronous interrupt-and-resume needed three methods.
The base class is not an ABC. Each storage method is a bare raise NotImplementedError, so a missing method fails only when a run calls it.
This is a reduction of GitLab's pattern, not GitLab's code:
# Reduction, not GitLab's code: a saver whose only state is an external "product DB".
from typing import TypedDict
from langgraph.checkpoint.base import BaseCheckpointSaver, CheckpointTuple
from langgraph.graph import StateGraph, START, END
from langgraph.types import Command, interrupt
product_db: dict = {} # stands in for the product database behind an HTTP API
row_for = lambda tid: product_db.setdefault(tid, {"tid": tid, "ckpts": {}, "writes": {}})
class DictSaver(BaseCheckpointSaver):
def get_tuple(self, config):
row = product_db.get(config["configurable"]["thread_id"])
if not row: return None
cid = config["configurable"].get("checkpoint_id") or row["latest"]
ckpt, meta, parent = (self.serde.loads_typed(b) for b in row["ckpts"][cid])
writes = [(t, c, self.serde.loads_typed(v)) for t, c, v in row["writes"].get(cid, [])]
cfg = lambda i: {"configurable": {"thread_id": row["tid"], "checkpoint_ns": "", "checkpoint_id": i}}
return CheckpointTuple(cfg(cid), ckpt, meta, parent and cfg(parent), writes)
def put(self, config, checkpoint, metadata, new_versions):
tid, parent = config["configurable"]["thread_id"], config["configurable"].get("checkpoint_id")
row = row_for(tid)
row["ckpts"][checkpoint["id"]] = tuple(self.serde.dumps_typed(x) for x in (checkpoint, metadata, parent))
row["latest"] = checkpoint["id"]
return {"configurable": {"thread_id": tid, "checkpoint_ns": "", "checkpoint_id": checkpoint["id"]}}
def put_writes(self, config, writes, task_id, task_path=""):
row = row_for(config["configurable"]["thread_id"])
row["writes"].setdefault(config["configurable"]["checkpoint_id"], []).extend(
(task_id, c, self.serde.dumps_typed(v)) for c, v in writes)
class S(TypedDict):
plan: str
approved: str
def ask(s: S): return {"approved": interrupt({"question": f"approve {s['plan']}?"})}
def build(): # what every request does: compile a fresh graph around a fresh saver
g = StateGraph(S); g.add_node("ask", ask); g.add_edge(START, "ask"); g.add_edge("ask", END)
return g.compile(checkpointer=DictSaver())
cfg = {"configurable": {"thread_id": "workflow-42"}}
out = build().invoke({"plan": "refactor"}, cfg) # request 1: a fresh graph and saver
print("request 1:", {k: v for k, v in out.items() if k != "__interrupt__"}, "paused on", [i.value for i in out["__interrupt__"]])
g2 = build(); print("request 2:", g2.invoke(Command(resume="yes"), cfg))
print("db rows:", {k: (len(v["ckpts"]), sum(map(len, v["writes"].values()))) for k, v in product_db.items()})
request 1: {'plan': 'refactor'} paused on [{'question': 'approve refactor?'}]
request 2: {'plan': 'refactor', 'approved': 'yes'}
db rows: {'workflow-42': (3, 6)}
Request 2 never saw request 1's objects. The dict alone carried the pause.
The interrupt is stored as a pending write, not inside the checkpoint. That is why GitLab's aput_writes keeps exactly one kind of write:
# for now only interrupts are stored
if not writes:
return None
step = str(checkpoint_id)
if writes[0][0] == INTERRUPT:
self._paused_tasks[step].add(task_id)
self._steps_with_a_pause.add(step)
Excerpt from GitLab's ai-assist, GitLab Enterprise Edition licence (LICENSE); gitlab_workflow.py L2306-L2320.
One edge probe matters more than the others. I sent a resume to a thread id the store had never seen, and it was not rejected. The graph started from scratch and failed in the node with KeyError: 'plan'. When I made the node tolerant, it dropped the resume value and asked for approval again.
So a mismatched thread id or a wiped store doesn't return "not found". It silently throws away the user's approval and starts the workflow over.
I did not test HTTP, latency, concurrency, subgraphs, or GitLab's own saver.
Custom checkpointer trade-offs, and why GitLab still chose one
The strongest version of the opposing view goes like this. GitLab's saver is a second copy of LangGraph's persistence layer, split across ai-assist and Rails and coupled to LangGraph internals. Every write is relayed through the user's own client.
GitLab's own records support the critics:
- Payload size. ADR 005 (n.d.) records "A simple workflow transferred 3 MiB of data with individual checkpoint updates reaching 150 KiB ."
- Storage growth. Epic &22628 (2026) shows the 30-day checkpoint table growing from 453 GB to 2.65 TB. GitLab answered with hand-built per-channel deltas and reported "a measured ~63× storage reduction". The epic's snapshot still showed rollout flags at 50%, so I could not confirm which save strategy production runs today. LangGraph now ships
DeltaChannelin beta for the same problem; nothing I read shows GitLab using it. - Pending writes. The saver drops them. With pending writes, LangChain docs (n.d.) note that on resume "you don't re-run the successful nodes." Without them, a crash mid-super-step likely re-runs every task of that step, including tool actions the client already executed. That comes from the code, not a test.
- Upgrades. The docs (n.d.) warn that new metadata fields arrive "in minor releases; discarding them silently breaks features." I infer that every LangGraph minor bump becomes a change in two repos.
I concede all of it. The material cannot show that this trade is cheap.
It does show that the trade was forced. MR !156872 (n.d.) states: "The AI Gateway does not have any database so the main GitLab rails application will be the source of truth for persisting state of the running workflow." Work item 596718 (n.d.) marks LangGraph "SM data residency compatible | ✓ (custom saver)". My inference is that this row refers to self-managed instances.
Given those constraints, Agent Server doesn't fit either. LangSmith "always requires PostgreSQL" (LangChain (n.d.)), and custom checkpointers there "are in alpha" (LangChain (n.d.)).
Custom checkpointer, PostgresSaver or no checkpointer: which to choose
- Stock AsyncPostgresSaver on your own database. You get pending writes and pruning for free, at the cost of a second source of truth. Choose it when the service may hold a database credential.
- GitLab's route. You own the persistence layer and its upgrade path. Every write pays a round trip through the client, and skipped sibling writes are lost on a crash. Choose it when the service must hold no credential and the product already stores the session.
- No checkpointer, as Kibana does. You can pause only at node boundaries, and there is no crash resume. Choose it when pauses fall at tool boundaries.
- Agent Server. It brings its own Postgres for threads and runs, and custom savers there are alpha. Choose it when a second database alongside the product is acceptable.
The deciding question is not which saver to pick. It is who already owns the session row.
As I read it, GitLab's Rails knew each session's status, owner and billing before DWS ran a step. The checkpoint became one more field on a record that already existed. If your product owns that row, a custom saver is a schema decision. If it doesn't, you are building a database, and you should use one somebody else maintains.
FAQ
What is a custom checkpointer in LangGraph?
A subclass of BaseCheckpointSaver that stores checkpoints wherever you choose. The docs list five required methods; on langgraph 1.2.14 a synchronous interrupt-and-resume needed three of them: get_tuple, put and put_writes.
Can a LangGraph agent be stateless? Between requests, yes, if the checkpointer writes into a database the product already has. Inside a request it still holds the run in memory, as GitLab's design doc says.
How do you resume a LangGraph interrupt in a new process?
Compile a fresh graph around the same store and invoke it with the same thread id and Command(resume=...). A wrong thread id is not rejected: the run silently starts over.
Should I use a custom checkpointer or PostgresSaver? Use the stock saver when the service may hold a database credential. A custom checkpointer pays off only when the product already owns the session row.
