A LangGraph agent running on Ollama forgets everything the moment its Python process exits, unless you give it a checkpointer. Use PostgresSaver, the LangGraph Postgres checkpointer, and the agent keeps every thread across restarts, crashes and reboots. It can also park a risky tool call until a person approves it. This guide wires the two together on one Ubuntu server with no cloud API in the loop: Ollama serves a small tool-calling model on CPU, uv manages the Python project, and PostgresSaver writes each step of the graph to Postgres.
We don’t stop at “it saved a row”. The lab reboots the server in the middle of a pending approval and resumes the same thread, kills a run with kill -9 after its tool already ran, rejects a stale approval, and measures how fast the checkpoint tables grow. I confirmed everything below working on Ubuntu 26.04 with LangGraph 1.2.22 and langgraph-checkpoint-postgres 3.2.1 in November 2026, and repeated the install, setup and interrupt steps on Ubuntu 24.04.
Pick an Ollama model that can call tools
The agent is only as useful as the model’s tool calling, and on a CPU box the model size decides whether a turn takes seconds or minutes. We tried three models from the Ollama library on a 4 vCPU, 15 GB VM with no GPU. The numbers below are wall-clock times for one full turn (model, tool, model) as printed by the agent script you’ll build shortly.
| Model | Size on disk | Tool calls | One turn (warm) | Verdict |
|---|---|---|---|---|
| qwen3:4b | 2.5 GB | Yes | 141.7s and 145.3s | Correct call, but leaked its reasoning into the answer |
| qwen3:1.7b | 1.4 GB | Yes | 4.0s to 13.6s | Used for the rest of this guide |
| gemma3:1b | 806 MB | No | Fails at once | Ollama returns HTTP 400 “does not support tools” |
Even with reasoning=False, qwen3:4b answered with “Okay, let me see…” style thinking in the message content and needed well over two minutes per turn on CPU. The 1.7b tag made the same tool calls in a few seconds, so it is the default in the script. On a machine with a GPU, swap in a bigger model through the AGENT_MODEL variable without touching the code. The open source LLM comparison table helps if you want to shortlist other tool-capable models.
Install PostgreSQL, Ollama and uv
All three run on the same host in this build. The steps are the same on Ubuntu 26.04 and 24.04. What differs is the PostgreSQL version apt pulls (18 on 26.04, 16 on 24.04) and the Python uv picks up (3.14 on 26.04, the system 3.12 on 24.04), and the checkpointer worked with both pairs.
- Install PostgreSQL from the Ubuntu archive.
- Install Ollama with its official script, which also creates and starts the
ollamasystemd service. - Install uv for your user, then pull the model.
sudo apt-get update
sudo apt-get install -y postgresql
curl -fsSL https://ollama.com/install.sh | sh
curl -LsSf https://astral.sh/uv/install.sh | sh
source ~/.local/bin/env
until curl -fs http://127.0.0.1:11434/ >/dev/null; do sleep 1; done
ollama pull qwen3:1.7b
The until loop isn’t decoration. On our Ubuntu 24.04 run, a pull straight after the installer failed with Error: could not connect to ollama server, run 'ollama serve' to start it, because the freshly started service wasn’t listening yet. Waiting for port 11434 to answer avoids that race in scripts and cloud-init.
Both PostgreSQL and Ollama start at boot by default, which matters later when we reboot the box mid-approval. Confirm both units are enabled and active before going further:
systemctl is-enabled postgresql ollama
systemctl is-active postgresql ollama
Each command should print enabled or active twice. If you’d rather tune PostgreSQL first (listen address, pg_hba.conf, memory), our PostgreSQL 18 install walkthrough covers that, and the Ollama setup guide adds Open WebUI on the same host if you want a chat front end next to the agent.
Give the agent its own Postgres role and database
Keep the checkpoints out of the postgres superuser account. A dedicated role that owns one database is enough, because setup() only creates tables and indexes inside the database it connects to. Export the connection details once so every later command reuses them:
export AGENT_DB_PASS="ChangeMe-Agent2026"
export AGENT_DB_URI="postgresql://agent:${AGENT_DB_PASS}@localhost:5432/agent"
Pick a real password before you paste the first line, because the same string ends up in the role and in every connection the agent opens. Stick to letters, digits, hyphens and underscores: an @, :, / or % breaks the URI unless you percent-encode it, and a single quote breaks the SQL below. Then create the role and the database it owns, in one psql call as the postgres user.
sudo -u postgres psql -c "CREATE ROLE agent LOGIN PASSWORD '${AGENT_DB_PASS}';" -c "CREATE DATABASE agent OWNER agent;"
psql answers with CREATE ROLE and CREATE DATABASE. A quick login proves the URI works before Python gets involved:
psql "$AGENT_DB_URI" -c "SELECT current_user, current_database();"
Both columns should read agent. Add the two export lines to ~/.bashrc if you plan to come back to this in a new shell, since every uv run below reads AGENT_DB_URI from the environment.
Create the project with uv
The agent needs four packages: langgraph for the graph, langgraph-checkpoint-postgres for PostgresSaver, psycopg with its binary and pool extras as the driver, and langchain-ollama for the chat model. uv picks a matching Python on its own, so you don’t need to touch the system interpreter.
mkdir -p ~/agent && cd ~/agent
uv init --bare
uv add langgraph langgraph-checkpoint-postgres "psycopg[binary,pool]" langchain-ollama
One thing caught us here. The first uv add resolved the previous langgraph release from uv’s cached index even though a newer one had shipped hours earlier. If you’re chasing a fix from a fresh release, force uv to look again:
uv lock --upgrade --refresh
uv sync
Now check what actually landed in the virtual environment, along with the server side versions:
uv pip list | grep -E '^(langgraph|langchain|psycopg|ollama)'
Our lab printed this set, which is the combination every capture in this guide comes from:

Notice langgraph-checkpoint and langgraph-prebuilt arrive as dependencies. The Postgres saver tracks the checkpoint base package closely, so upgrade them together rather than bumping one package on its own.
On Ubuntu 24.04 the same uv add resolved the same LangGraph, saver and psycopg versions on top of the system Python 3.12. We ran the setup, an interrupt and a strict approval there too, using the agent script from the next section unchanged:

Everything from here on was captured on the 26.04 server, but nothing in the flow depends on the release.
Write the agent graph and point it at Postgres
The script below is the exact file that produced every capture in this guide. It builds a two node graph: an agent node that calls the model, and a tools node that runs whatever the model asked for. Three tools give it something to do on a Linux box: report disk usage, list files in a scratch directory, and delete files there. Only the delete tool is dangerous, so only the delete tool calls interrupt().
Create the scratch directory with a few sample files first, so the tools have something to find:
sudo mkdir -p /srv/agent-scratch && sudo chown $USER: /srv/agent-scratch
cd /srv/agent-scratch
for d in 01 02 03; do head -c $((RANDOM*40)) /dev/urandom > app-2026-11-$d.log; done
head -c 2048 /dev/urandom > config.yaml
cd ~/agent
The log sizes are random on purpose, so your list_files output will show different byte counts from ours. Only config.yaml has a fixed size of 2048 bytes.
Open a new file in the project directory. We keep the script in one file on purpose, so the graph, the tools and the command line flags you’ll use in every later step sit side by side.
vim ~/agent/agent.py
Paste the full script as it is. The flags at the bottom (--setup, --history, --resume, --continue, --strict) map one to one onto the sections that follow.
import argparse
import os
import shutil
import sys
import time
from importlib.metadata import version
from pathlib import Path
from typing import Annotated, TypedDict
from langchain_core.messages import AnyMessage, HumanMessage, SystemMessage
from langchain_core.tools import tool
from langchain_ollama import ChatOllama
from langgraph.checkpoint.postgres import PostgresSaver
from langgraph.graph import START, StateGraph
from langgraph.graph.message import add_messages
from langgraph.prebuilt import ToolNode, tools_condition
from langgraph.types import Command, interrupt
DB_URI = os.environ["AGENT_DB_URI"]
MODEL = os.environ.get("AGENT_MODEL", "qwen3:1.7b")
SCRATCH = Path(os.environ.get("AGENT_SCRATCH", "/srv/agent-scratch"))
SYSTEM = (
f"You are an ops assistant on a Linux server. You may only touch files under {SCRATCH}. "
"Use the tools to answer. Keep answers to two sentences."
)
@tool
def disk_usage(path: str) -> str:
"""Report total, used and free space of the filesystem that holds path."""
total, used, free = shutil.disk_usage(path)
gib = 1024**3
return f"{path}: total {total / gib:.1f} GiB, used {used / gib:.1f} GiB, free {free / gib:.1f} GiB"
@tool
def list_files(pattern: str = "*") -> str:
"""List files and their sizes in the scratch directory that match a glob pattern."""
files = sorted(SCRATCH.glob(pattern))
return "\n".join(f"{f.name} {f.stat().st_size} bytes" for f in files) or "no files match"
@tool
def delete_files(pattern: str) -> str:
"""Delete files in the scratch directory that match a glob pattern such as '*.log'."""
matches = sorted(SCRATCH.glob(pattern))
# Everything above interrupt() runs again on resume, so keep it free of side effects.
answer = interrupt({"tool": "delete_files", "pattern": pattern, "files": [m.name for m in matches]})
if answer != "approve":
return f"Operator rejected deleting {len(matches)} file(s) matching {pattern}."
for m in matches:
m.unlink()
return f"Deleted {len(matches)} file(s): {', '.join(m.name for m in matches)}"
TOOLS = [disk_usage, list_files, delete_files]
class State(TypedDict):
messages: Annotated[list[AnyMessage], add_messages]
def build(checkpointer):
llm = ChatOllama(model=MODEL, temperature=0, reasoning=False).bind_tools(TOOLS)
def agent(state: State):
return {"messages": [llm.invoke([SystemMessage(SYSTEM)] + state["messages"])]}
graph = StateGraph(State)
graph.add_node("agent", agent)
graph.add_node("tools", ToolNode(TOOLS))
graph.add_edge(START, "agent")
graph.add_conditional_edges("agent", tools_condition)
graph.add_edge("tools", "agent")
return graph.compile(checkpointer=checkpointer)
def show(update):
for node, data in update.items():
if node == "__interrupt__":
for i in data:
print(f"[paused] {i.value} id={i.id}", flush=True)
continue
for msg in (data or {}).get("messages", []):
calls = getattr(msg, "tool_calls", None)
if calls:
for c in calls:
print(f"[{node}] call {c['name']}({c['args']})", flush=True)
else:
print(f"[{node}] {msg.content.strip()[:300]}", flush=True)
def main():
p = argparse.ArgumentParser()
p.add_argument("--thread", default="ops-1")
p.add_argument("--setup", action="store_true", help="create the checkpoint tables")
p.add_argument("--history", action="store_true", help="print the saved transcript")
p.add_argument("--continue", dest="cont", action="store_true", help="finish a run that died mid-way")
p.add_argument("--resume", help="answer a pending interrupt, e.g. approve or reject")
p.add_argument("--interrupt-id", help="answer this interrupt id instead of the pending one")
p.add_argument("--strict", action="store_true", help="refuse stale or unknown interrupt answers")
p.add_argument("message", nargs="?")
args = p.parse_args()
with PostgresSaver.from_conn_string(DB_URI) as saver:
if args.setup:
saver.setup()
print("checkpoint tables ready")
return
app = build(saver)
config = {"configurable": {"thread_id": args.thread}}
if args.strict:
config["configurable"]["__pregel_strict_resume"] = True
if args.history:
state = app.get_state(config)
for m in state.values.get("messages", []):
text = m.content.strip() or f"(tool call: {m.tool_calls[0]['name']})"
print(f"{m.type:>5}: {text[:200]}")
print(f"next: {state.next or '()'} pending interrupts: {len(state.interrupts)}")
return
if args.resume:
if args.interrupt_id:
payload = Command(resume={args.interrupt_id: args.resume})
else:
payload = Command(resume=args.resume)
elif args.cont:
payload = None
else:
payload = {"messages": [HumanMessage(args.message)]}
print(f"langgraph {version('langgraph')} | checkpoint-postgres {version('langgraph-checkpoint-postgres')} "
f"| model {MODEL} | thread {args.thread}", flush=True)
start = time.perf_counter()
for update in app.stream(payload, config, stream_mode="updates"):
show(update)
print(f"({time.perf_counter() - start:.1f}s)")
if __name__ == "__main__":
sys.exit(main())
A few lines carry the whole persistence story, and they are the ones you will change first when you adapt this to your own agent.
PostgresSaver.from_conn_string(DB_URI)opens the connection with autocommit on and dict rows, the two settings the saver needs. Building your own psycopg connection without them is the most common way to break it (see the errors section).graph.compile(checkpointer=checkpointer)makes LangGraph write a checkpoint after every step. Thethread_idin the config is the key: same id, same conversation, no matter which process asks.interrupt()insidedelete_filesstops the graph and saves the pending call. The comment above it is the rule that bites people: on resume, the tool function runs again from the top, so nothing beforeinterrupt()may change the system.__pregel_strict_resumeswitches on strict resume, a recent addition to LangGraph. It is a private config key today, so treat it as subject to change. We test what it does below.
The add_messages reducer means every checkpoint stores the full message list for the thread. That is what makes the history survive a reboot, and it’s also why the tables grow faster than you’d guess, as the retention section shows.
Create the checkpoint tables with setup()
PostgresSaver does not create its schema on first use. Call setup() once per database, at deploy time, and again after you upgrade the package so any new migrations run. The script’s --setup flag does just that:
cd ~/agent
uv run agent.py --setup
psql "$AGENT_DB_URI" -c "\dt"
Four tables appear, all owned by the agent role, and checkpoint_migrations records the schema version the saver applied:

checkpoints holds one row per step with the channel versions, checkpoint_blobs holds the serialized channel values (the message list lives here), and checkpoint_writes keeps interrupt records plus the output of tasks that finished inside a step that didn’t. Between them, a run that dies at any point can pick up from the last saved step.
Talk to the agent on one thread
Every run below uses the default thread ops-1 unless a --thread flag says otherwise. Ask two questions, each in a separate process:
uv run agent.py "How much free space is on the root filesystem?"
uv run agent.py "Which log files are in the scratch directory and how big are they?"
Each process exits after its answer, yet the second one still knows what the conversation is about. The model picked the right tool both times:

Turn one took 4.0 seconds and turn two 11.6 seconds, because the second prompt carries the whole first exchange. That is the cost of thread memory on a CPU model: every turn re-reads everything that came before it.
Pause the delete tool with interrupt() and reboot
Now ask for something destructive. The model will call delete_files, and the tool will stop at interrupt() before touching a file. Then reboot the whole server while the approval is still pending, which is the harshest test of whether the pause really lives in Postgres and not in memory.
uv run agent.py "Delete all of those log files."
sudo systemctl reboot
After the server comes back, log in again, re-export AGENT_DB_URI if it isn’t in your shell profile, and ask for the saved transcript:
cd ~/agent
uptime -s
uv run agent.py --history
The pause printed the interrupt payload and its id, and after the reboot the thread is still parked on the tools node with one pending interrupt:

The new boot time proves this is a fresh boot, not the same session. All three log files were still on disk at this point, because unlink() sits after interrupt(). Hold on to the interrupt id af24da74... from our run, because you will use it to test a stale answer in a moment.
Approve the call with Command(resume=…) under strict mode
To answer an interrupt you send Command(resume=value) instead of a new message. With one pending interrupt a plain value is enough, and with several you pass a dict of {interrupt_id: value}. Strict mode, which needs langgraph 1.2.20 or later (see the LangGraph release notes), makes LangGraph refuse an answer that doesn’t match a pending interrupt instead of quietly dropping it. Approve the delete, then replay the same answer with the old id:
uv run agent.py --strict --resume approve
ls /srv/agent-scratch
uv run agent.py --strict --resume approve --interrupt-id af24da74d6628d9247a29750cd80bca7
uv run agent.py --resume approve --interrupt-id af24da74d6628d9247a29750cd80bca7
Replace the id with the one your own run printed. Here is what each command did on our server:

The approval deleted the three logs and left only config.yaml. That turn took 40.5 seconds because Ollama had to load the model cold after the reboot. The replay is the interesting part: in strict mode LangGraph raised UnknownInterruptError before writing anything. Without --strict the same stale answer printed nothing and finished in 0.0 seconds, so the caller can’t tell its approval was thrown away. If an approval UI or a queue can deliver a click twice, turn strict mode on, and pass the interrupt id with every answer when you can. Upstream is still refining how a bare value binds to a single pending interrupt in strict mode, while an answer keyed by id is unambiguous.
Rejecting works the same way. On a second thread, ask the agent to delete the config file and answer reject:
uv run agent.py --thread ops-2 "Delete config.yaml from the scratch directory."
uv run agent.py --thread ops-2 --strict --resume reject
The tool returns the rejection to the model as its result, and the file stays put:

Read the model’s reply carefully. It told the user to “verify the permissions or ownership of the file”, which is invented: nobody mentioned permissions, a person simply said no. Small models fill gaps with confident guesses, so if the reason matters, put it in the tool’s return string (“Operator rejected…”) and tell the model in the system prompt to repeat it word for word.
Finish a run that was killed mid-way
A reboot during a pause is the easy case, because the graph was already waiting. The harder case is a process that dies between steps: the tool ran, its result was saved, but the model never got to answer. We started a run in the background with its output going to a file, waited for the [tools] line to appear, and killed the process with SIGKILL so no cleanup code could run. The wait matters because the model’s follow-up call is quick, so a kill sent too late finds a finished run. Delete any /tmp/run.out left from an earlier try first, or the loop can match its old [tools] line and kill the run before the tool starts. If the model answers without calling the tool, the loop never ends; press Ctrl+C and run it again:
uv run agent.py --thread ops-1 "Call list_files to check what is really in the scratch directory now." > /tmp/run.out 2>&1 &
until grep -q '^\[tools\]' /tmp/run.out; do sleep 0.2; done; pkill -9 -f "agent.py --thread ops-1"
cat /tmp/run.out
The output should stop on the tool result, with no answer from the agent after it. Check what the thread looks like now, then finish it:
uv run agent.py --history | tail -3
uv run agent.py --continue
The --continue flag streams None as the input, which tells LangGraph to carry on from the last checkpoint instead of starting a new turn:

After the kill, the history ends on the tool result with next: ('agent',). The continued run went straight to the model and answered in 1.5 seconds. list_files did not run a second time. That is the property you want for tools with side effects: a step that completed and was checkpointed is never replayed. Be careful with pkill -f in a wrapper script, though. If the pattern also matches the shell that launched the agent, you kill the wrapper too, which is exactly what happened to us when we ran this block as one bash -c string over SSH.
One last memory check on the same thread, after the reboot and the kill, asked the agent what it had deleted earlier. It answered “You deleted the log files app-2026-11-01.log, app-2026-11-02.log, and app-2026-11-03.log.” from the stored messages alone.
Measure checkpoint growth and prune old threads
Nothing in PostgresSaver expires old checkpoints, and the LangGraph persistence docs list “checkpoints growing unboundedly” as a known issue to plan for. To put numbers on it we ran 20 turns on a fresh thread called load-1, each one calling both disk_usage and list_files, then counted rows with this query file:
vim ~/agent/stats.sql
It reports checkpoints per thread, then rows and on-disk size for each table. We use pg_total_relation_size because it counts TOAST and indexes, which is where most of the blob data ends up.
SELECT thread_id, count(*) AS checkpoints,
max(checkpoint->>'ts') AS last_write
FROM checkpoints GROUP BY thread_id ORDER BY thread_id;
SELECT 'checkpoints' AS tbl, count(*) AS row_count, pg_size_pretty(pg_total_relation_size('checkpoints')) AS size FROM checkpoints
UNION ALL
SELECT 'checkpoint_blobs', count(*), pg_size_pretty(pg_total_relation_size('checkpoint_blobs')) FROM checkpoint_blobs
UNION ALL
SELECT 'checkpoint_writes', count(*), pg_size_pretty(pg_total_relation_size('checkpoint_writes')) FROM checkpoint_writes;
The 20 turns added exactly 100 checkpoints, five per turn: the input, the start of the step loop, the model call, the tool call and the final answer. Against the two threads that existed before the load run, the tables moved like this.
| Measurement | Before (ops-1, ops-2) | After 20 turns on load-1 |
|---|---|---|
| checkpoints rows / size | 31 / 104 kB | 131 / 208 kB |
| checkpoint_blobs rows / size | 31 / 152 kB | 131 / 608 kB |
| checkpoint_writes rows / size | 47 / 88 kB | 187 / 192 kB |
| Raw blob payload for load-1 | n/a | 1696 kB in 100 blobs |
| Turn time, first vs twentieth | n/a | 6.7s vs 13.6s |
The blob payload grows faster than linearly, because each new messages blob contains every earlier message on the thread. Postgres compresses large values, so the whole blobs table for all three threads still sat well under load-1’s raw payload, but a long-lived support thread will still bloat. The turn time doubled over the same 20 turns. We didn’t time the database calls separately, but the growing prompt the model re-reads each turn is the likely cause rather than Postgres.
The saver ships two cleanup methods. delete_thread(thread_id) drops one thread, and prune(thread_ids, strategy=...) either deletes threads ("delete") or trims them to their latest checkpoint ("keep_latest"). We wrapped both in a small script that trims named threads and deletes any thread idle longer than a cutoff:
vim ~/agent/prune.py
Paste this version, which is the one we ran. The stale-thread query reads the timestamp stored inside each checkpoint, so it needs no extra column or trigger.
import argparse
import os
from langgraph.checkpoint.postgres import PostgresSaver
STALE_THREADS = """
SELECT thread_id FROM checkpoints
GROUP BY thread_id
HAVING max((checkpoint->>'ts')::timestamptz) < now() - make_interval(days => %s)
"""
p = argparse.ArgumentParser()
p.add_argument("--older-than-days", type=int, default=30, help="delete threads idle this long")
p.add_argument("--keep-latest", nargs="*", default=[], help="threads to trim to their latest checkpoint")
args = p.parse_args()
with PostgresSaver.from_conn_string(os.environ["AGENT_DB_URI"]) as saver:
if args.keep_latest:
saver.prune(args.keep_latest, strategy="keep_latest")
print(f"trimmed to latest checkpoint: {', '.join(args.keep_latest)}")
with saver.conn.cursor() as cur:
stale = [r["thread_id"] for r in cur.execute(STALE_THREADS, (args.older_than_days,))]
saver.prune(stale, strategy="delete")
print(f"deleted {len(stale)} thread(s) idle more than {args.older_than_days} days: {', '.join(stale) or '-'}")
prune() takes a list of thread ids, never a bare string. Trim the two long threads, delete anything idle for 30 days, and check the tables again. Deleted rows don’t hand space back to the OS on their own, so the last command runs VACUUM FULL to show the real reclaimable size:
psql "$AGENT_DB_URI" -f stats.sql
uv run prune.py --keep-latest load-1 ops-1 --older-than-days 30
psql "$AGENT_DB_URI" -c "VACUUM FULL checkpoints, checkpoint_blobs, checkpoint_writes;" -f stats.sql
load-1 dropped from 100 checkpoints to 1 and ops-1 from 26 to 1, while ops-2 kept its 5 because it wasn’t listed:

Before the vacuum the sizes didn’t move at all (208 kB, 608 kB, 192 kB), even with 124 checkpoint rows gone. After VACUUM FULL the three tables shrank to 48 kB, 72 kB and 48 kB. Plain autovacuum makes the freed space reusable for new checkpoints, which is usually all you need. Save VACUUM FULL for a maintenance window, since it locks the tables. Trimming doesn’t erase memory either: --history on ops-1 still printed the whole conversation, and load-1 still had all 20 human messages, because the latest checkpoint carries the full message list.
Run the prune script from a systemd timer or cron once a day. If your agent needs facts that outlive a thread, store them separately: the checkpointer is short-term, per-thread memory, and the Hindsight agent memory setup shows one way to keep long-term memory on the same Ollama host.
Fix the errors we hit along the way
Every error below came up during the lab runs. The messages are copied exactly as they appeared, so you can search for them.
psycopg.errors.UndefinedTable: relation “checkpoints” does not exist
This is the first error almost everyone meets. The graph tried to read the latest checkpoint for the thread before setup() had ever run against that database:
psycopg.errors.UndefinedTable: relation "checkpoints" does not exist
LINE 26: from checkpoints WHERE thread_id = $1 AND checkpoint_ns = $2...
^
Run uv run agent.py --setup once, or call saver.setup() in your deploy step. It is idempotent, so calling it on every start is safe if you prefer that.
ActiveSqlTransaction: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
This one shows up when you create the psycopg connection yourself, for example to share a pool, and pass it to PostgresSaver(conn). Our repro connected with defaults and called setup():
psycopg.errors.ActiveSqlTransaction: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
The migrations build indexes concurrently, which Postgres forbids inside a transaction, and psycopg opens one implicitly unless autocommit is on. \dt afterwards showed no tables at all. Connecting with Connection.connect(DB_URI, autocommit=True) fixed it, and the four tables appeared. The package README also asks for row_factory=dict_row on manual connections. In our test the saver set dict rows on its own cursors anyway. To match exactly what from_conn_string() does, connect with autocommit=True, prepare_threshold=0, row_factory=dict_row.
ollama._types.ResponseError: registry.ollama.ai/library/gemma3:1b does not support tools (status code: 400)
Pointing the agent at a model without tool support fails on the first turn, inside the agent node:

Check the model’s capabilities before you pull it. The tags page on ollama.com lists “tools” for models that support it, and ollama show qwen3:1.7b prints a Capabilities block locally. For qwen3:1.7b that block lists completion, tools and thinking, while gemma3:1b lists only completion. Switch with AGENT_MODEL=qwen3:1.7b or another tool-capable tag.
langgraph.errors.UnknownInterruptError: Unknown or already-consumed interrupt
You’ll only see this with strict resume on, and it’s doing its job: the interrupt id you answered isn’t pending on the thread anymore. Read the current state with app.get_state(config).interrupts (our --history flag prints the count) and answer the id that’s actually there, or drop the request if the action was already approved.
Stop the agent answering from memory instead of calling a tool
This isn’t an exception, which makes it worse. After the logs were deleted we asked “What files are left in the scratch directory?” and qwen3:1.7b answered “The scratch directory contains no files left after deleting the log files.” without calling list_files. config.yaml was sitting right there. Thread memory makes this more likely: the model sees an earlier answer in its context and trusts it over the filesystem. Asking it explicitly to call the tool fixed that turn. For production, state in the system prompt that file questions must always go through a tool, or route those questions to the tool in code.
Connect the checkpointer to the rest of your stack
The same Postgres database can carry more than checkpoints, and the same Ollama host can serve more than one agent. This is how the pieces line up with other builds on the site:
| You want to add | Where it plugs in | What to watch |
|---|---|---|
| Document retrieval | A retriever tool in TOOLS, backed by Qdrant with LangChain or pgvector in the same Postgres | Retrieved chunks land in the message list and inflate every later checkpoint |
| Choosing a vector store | Our Qdrant, Weaviate, Milvus and pgvector benchmark | pgvector keeps one database to back up, the others scale out further |
| RAG framework choice | The LangChain vs LlamaIndex Ollama benchmark | LangGraph only needs a callable tool, so either framework works behind it |
| External tools over MCP | MCP servers exposed as tools; see MCP vs RAG vs agent skills | Wrap anything destructive in interrupt() the same way as delete_files |
| Smaller prompts on long threads | Trim or summarize messages before llm.invoke, as covered in context engineering for agents | Turn time doubled over 20 turns in our load test |
Whatever you bolt on, keep the two habits from this build: anything that changes the system goes behind interrupt() with nothing destructive above it, and a scheduled prune keeps the checkpoint tables from quietly filling the disk. If you want the design side of multi-agent systems in more depth, our AI agent book picks are a good next read.