durable_llm_graph

command
v0.10.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2026 License: MIT Imports: 9 Imported by: 0

README

durable_llm_graph

Shows where LLM calls happen in Chronos and how the StateGraph runtime makes them durable.

The graph is a 3-step pipeline where the LLM is called inside nodes:

draft (LLM) ──▶ review (LLM) ──▶ finalize

review is rigged to fail on its first attempt to simulate a crash after the expensive draft LLM call has completed. The runner checkpoints state after every completed node, so on Resume:

  • draft is not re-executed (its output was checkpointed) — its LLM call does not repeat, and its 🔵 [draft] log line does not print again.
  • execution picks up at review, then finishes at finalize.

Key point: engine/graph never calls an LLM itself — it only orchestrates and checkpoints. LLM calls live in the node functions (sdk/agent does the same one layer up). The example uses a deterministic offline stub model.Provider; swap in OpenAI/Anthropic/Gemini/Ollama and the graph code is unchanged.

Run

go run ./examples/durable_llm_graph/
go test ./examples/durable_llm_graph/

See also: examples/graph_with_llm (real providers + tools) and examples/durable_hitl (interrupt-node human approval).

Documentation

Overview

Example: durable_llm_graph — where LLM calls happen, and how the StateGraph runtime makes them durable.

What you'll learn:

  • LLM calls happen INSIDE graph nodes (the runtime itself is LLM-agnostic).
  • The runner checkpoints state after every node that completes.
  • When a later node fails (a crash, a transient provider/network error, a process restart), Resume continues from the last checkpoint — so a completed, EXPENSIVE LLM node is never re-executed.

The graph is a 3-step content pipeline:

draft (LLM) ──▶ review (LLM) ──▶ finalize

We deliberately make `review` fail on its first attempt to simulate a crash after `draft` has already done its expensive LLM work. On Resume, `draft` is skipped (its output was checkpointed) and execution picks up at `review`.

This example uses a deterministic stub Provider so it runs offline and in CI with no API keys. Swap it for a real provider (OpenAI/Anthropic/Gemini/Ollama) and the graph code does not change — that is the whole point of the model.Provider interface. See examples/graph_with_llm for a real-provider version.

Run:

go run ./examples/durable_llm_graph/

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL