Menu

Durable AI agents: LangGraph with Postgres checkpointing and a human approval gate
📰

Durable AI agents: LangGraph with Postgres checkpointing and a human approval gate

DEV Community: postgres·Trevor Ogina·6 days ago
#sZz4mEj8
#devtopostgresql#devto#dev#state#draft
Reading 0:00
15s threshold

Most agent demos keep their state in memory and act without asking anyone. That's fine for a notebook, but it isn't acceptable when the agent can send an email or submit something on a user's behalf.

When I built a multi-stage automation agent in Python, I needed two properties:

Durability : if the process restarts halfway through a run, the run picks up where it left off.

A human gate : before any step with an external side effect, the agent stops and waits for a person to approve.

LangGraph provides both, through checkpointers and interrupts . Here is the minimal version of the pattern.

The graph

Three nodes: draft something, wait for approval, then act on it.

from typing import TypedDict from langgraph.graph import StateGraph , START , END from langgraph.types import interrupt , Command

class State ( TypedDict ): task : str draft : str approved : bool

def draft_node ( state : State ) -> dict : # call your LLM here; validate its output with Pydantic before trusting it return { " draft " : f "…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.