Skip to content

Build a Resumable LangGraph Workflow

Category AI Solutions Engineering
Status โœ… Completed
Repo nextwork-build-a-resumable-langgraph-workflow
Original NextWork guide nextwork.ai

Learning project

Practice work following a NextWork guide, separate from my production projects.

๐Ÿ“š NextWork learning project. This is a practice project I built while working through NextWork's Build a Resumable LangGraph Workflow guide. It is part of my Learning portfolio and is fully separate from my production projects.

Category: Learning โ€บ AI Solutions Engineering
Status: โœ… Completed

Overview

This project starts with a deliberately unsafe auto-publisher, where the analysis goes straight to action. It then adds a risk policy: irreversible or all-user actions are high risk and pause at a human interrupt(). Every stage appends an audit event. The SQLite checkpointer lets a brand-new process pick up the paused incident and finish it.

Summary

The unsafe auto-publisher, then the risk policy plus human approval, an ordered audit trail, and resume-after-restart from SQLite all run, and the secret-mission checkpoint inspector reads saved state without resuming. The verification runs with a real model writing the incident summaries (local Ollama standing in for Gemini).

The checks behind this are in docs/verification.txt.

Skills & tools

LangGraph, Human-in-the-loop, Risk policies, Audit trails, SQLite checkpoints

What I built

  • workflow.py: the graph with --unsafe (step 1) vs policy and approval (steps 2-3), plus start/decide commands.
  • inspect_checkpoint.py: a read-only checkpoint inspector (secret mission).
  • demo.sh and test_workflow.py: 5 tests.

How to run

pip install -r requirements.txt
bash demo.sh

Verification

I ran the verification command on 2026-12-02. The full output is in docs/verification.txt.

PYTHON=/workspace/nextwork-portfolio/.venv/bin/python bash demo.sh && /workspace/nextwork-portfolio/.venv/bin/python -m pytest -q -p no:cacheprovider test_workflow.py

Notes

Model/provider substitution: the guide runs in Google Cloud Shell with Gemini. I ran locally: the risk analysis is deterministic over fictional incidents, and a local open model (qwen2.5:3b via Ollama, ANALYST_MODEL) writes each incident summary. The workflow, policy, approvals, audit trail, and checkpoints are the guide's deliverables.


Original project: https://nextwork.ai/projects/f94db9b2-1157-404b-a559-83e8752f2f86 ยท Part of my NextWork Learning portfolio (hub).

Verification output

From docs/verification.txt:

$ PYTHON=/workspace/nextwork-portfolio/.venv/bin/python bash demo.sh && /workspace/nextwork-portfolio/.venv/bin/python -m pytest -q -p no:cacheprovider test_workflow.py

== 1. the unsafe auto-publisher: a risky action goes out with no human ==
INC-7: next=done published=True
   {"t": "19:32:40", "stage": "analysis", "summary": "A significant portion of users experienced a login service unavailability, with 40% encountering a 503 Service Unavailable error following a recent configuration update.", "action": "Restart all auth pods and purge the session cache"}
   {"t": "19:32:40", "stage": "publish", "published": true, "action": "Restart all auth pods and purge the session cache"}

== 2. with risk policy: low-risk INC-8 publishes, high-risk INC-7 pauses ==
INC-8: next=done published=True
   {"t": "19:32:43", "stage": "analysis", "summary": "One sentence incident summary: Stale cache on marketing page led to outdated content for users.", "action": "Purge CDN cache for /pricing"}
   {"t": "19:32:43", "stage": "policy", "risk": "low", "rule": "irreversible or all-user blast radius => high"}
   {"t": "19:32:43", "stage": "publish", "published": true, "action": "Purge CDN cache for /pricing"}
INC-7: next=('approval',) published=False
   {"t": "19:32:47", "stage": "analysis", "summary": "A significant portion (40%) of users experienced a login service outage, resulting in a 503 Service Unavailable error after a configuration update.", "action": "Restart all auth pods and purge the session cache"}
   {"t": "19:32:47", "stage": "policy", "risk": "high", "rule": "irreversible or all-user blast radius => high"}

== 3. restart: a NEW process inspects the checkpoint read-only, then the operator approves ==
INC-7: 4 checkpoints saved
latest step: 2 | pending interrupt: True
risk: high | decision: (none yet) | published: False
audit events: 2
INC-7: next=done published=True
   {"t": "19:32:47", "stage": "analysis", "summary": "A significant portion (40%) of users experienced a login service outage, resulting in a 503 Service Unavailable error after a configuration update.", "action": "Restart all auth pods and purge the session cache"}
   {"t": "19:32:47", "stage": "policy", "risk": "high", "rule": "irreversible or all-user blast radius => high"}
   {"t": "19:32:48", "stage": "operator", "decision": "approve", "note": "Confirmed with auth on-call; restart in waves"}
   {"t": "19:32:48", "stage": "publish", "published": true, "action": "Restart all auth pods and purge the session cache"}
.....                                                                    [100%]
5 passed in 40.29s

[exit code 0]