Module 6 of 10, lesson 2 of 5
Going deeper
Choosing a framework
What you’re actually buying
The loop is easy to write. What takes months is everything around it, so judge a framework on those parts:
- Durable state: resuming after a crash or a long wait.
- Interrupts: pausing for a person and continuing.
- Traces: seeing each step of a failed run.
- Streaming: showing progress during a long task.
If you need none of these, a provider’s SDK and a loop will do, and you’ll have less to debug.
Reducers
In a graph, nodes return partial updates. If two branches write the same key in one step, something has to decide the result. LangGraph calls that function a reducer, and many confusing “lost message” bugs come from a missing one.
const reducers = { messages: (old, next) => [...old, ...next] };
// Two branches finish at the same step:
// { messages: ['A'] } and { messages: ['B'] }
// Without a reducer, one overwrites the other.
// With it: ['A', 'B'].
Checkpoints have rules
A checkpointer saves the state after each step, under a run id (LangGraph calls it a thread_id). Three consequences catch people out:
- A resumed node runs from its start. Any side effect before the crash can happen twice, so write nodes to be idempotent.
- An in-memory checkpointer survives no restart. It’s for tests.
- Saved states outlive your code. Changing the shape of the state means old runs must still load.
Trace before you need it
Multi-step failures can’t be read from final outputs. A useful trace links each run to its model calls, tool calls, arguments, results, tokens and duration. OpenTelemetry has semantic conventions for generative AI, which keeps your data portable. Tools such as LangSmith or Langfuse offer ready-made views. Decide early what must not be logged: traces collect personal data very easily.
Keep the exit open
The framework should sit around your logic, not inside it. Keep tools as plain functions, prompts in files and evaluations independent of the runtime. Then a migration means rewriting the wiring, not the product. The graph exercise in this module shows how little is at stake: a working engine fits in about twenty lines.