StudyVisuallyStart studying
Part 06 · LangChain / LangGraph · Card 12 of 14

Checkpointing

LangGraph saves the state after every step (in memory or Postgres). A conversation can resume tomorrow, and a crash doesn't lose progress.

Last updated

Analogy

Autosave in a game. Die at the boss and you restart at the last save point, not the title screen.

Code example

thread.tsTypeScript
const config = { configurable: { thread_id: "user-42" } };
await graph.invoke({ messages: [{ role: "user", content: "I'm Faisal" }] }, config);
await graph.invoke({ messages: [{ role: "user", content: "Who am I?" }] }, config);
// same thread_id -> the graph remembers

In an agent

Checkpoints give an agent working memory for multi-step tasks.

Practice

Flashcards

  • What does a checkpointer do?Saves agent state after each step so a run can resume later (LangGraph).
  • Interview: three kinds of agent memory?Short-term message history, long-term facts in a database, and working state in a checkpointer.
  • Interview: what does LangGraph add to LangChain?Explicit graphs with state, checkpoints, interrupts and routing, so complex agents are easier to control.

Interview questions

  • How do you handle memory?
    • Short-term memory is the message history, trimmed or summarized near the context limit.
    • Long-term facts go to a database and are retrieved when relevant.
    • For multi-step tasks, LangGraph checkpoints in Postgres hold the working state.

Questions people ask

What is checkpointing in LangGraph?

Checkpointing saves the graph's state after every step, in memory for development or in a database such as Postgres for production. Each conversation uses a thread_id. With the same thread_id, a conversation can resume tomorrow, and a crash in the middle of a task does not lose the progress already made.

How do LangGraph checkpoints give an agent memory?

Pass the same thread_id in the config on every call. LangGraph loads that thread's saved state, including the earlier messages, before running. So if a user says their name in one call, the agent still knows it in the next one, even days later, because the state was stored.