CourseAI System Design: The Complete Course · Module 8: Orchestration and State · part 58 of 107
Part 58 · Module 8: Orchestration and State

Lab: The Ask workflow, its sessions and its jobs

210 min read·
Module 8 · Lab · About 70 minutes · Needs: lessons 1 to 4 of this module, and the Module 7 lab (or nothing: Step 1 rebuilds Modules 1 to 7)

What you are building

A turn, and the night's jobs What this lab builds Active flow Background or async 1 Processing step number Client Quinn's question one turn An Ask turn LangGraph load history, memory answer Lesson 1's graph save both messages a checkpoint after every step (SqliteSaver) 1 2 3 Overnight RQ RQ: sync and Digest per tenant, two retries effect keys, dead letters tickets and emails, once
The lab's piece: a turn is load, answer and save (the stores yellow, the model step blue), checkpointed after each step (teal); background work runs on RQ with effect keys and a dead-letter list. Numbers give the order of a turn.

Gareth's question from Lesson 1 now has an answer in code. This lab puts the four lessons' files into the repository unchanged and joins them: Lesson 1's state machine runs on Module 6's permissioned retriever and Module 7's residency-filtered chain; each turn of a session carries Lesson 2's history and Lesson 3's memory and is checkpointed after every step; Lesson 4's jobs run a whole night for six tenants on RQ. ADR-005 records the background-work decision.

The new files are northdesk/ask_ports.py, northdesk/ask_turn.py, northdesk/digest.py, tests/test_workflow.py and tests/test_jobs.py. One cell calls your provider; every number quoted comes from a scripted model, fakeredis or no model at all. Open a new Colab notebook, module-08-lab.ipynb, and run each cell in order.

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.

Or open everything with a plan