All chapters
  1. Start hereSomething has to decide what runs next
  2. Foundations · 1Sequence, branch and loop: the three primitives of every workflow
  3. Foundations · 2State machines, DAGs, events and agent loops: four shapes of control
  4. Patterns · 3One agent with tools, or several specialized agents
  5. Patterns · 4Supervisor, planner-executor, router, swarm and peers: who talks to whom
  6. Patterns · 5Control plane and data plane: where code decides and where a model may
  7. Mechanics · 6Task queues, fan-out and fan-in, concurrency and rate limits
  8. Mechanics · 7Handoffs: what one agent must give the next
  9. Mechanics · 8Human approvals: pause, wait for a person, resume safely
  10. Production · 9Durable workflows: checkpoints, retries, compensation and cancellation
  11. Production · 10Permissions, budgets and termination: what a run may do, spend, and when it must stop
  12. Production · 11Failure propagation, circuit breakers and fallback routes
  13. Production · 12Trace propagation and outcome evaluation across a workflow
  14. Reference · 13Frameworks: LangGraph, Temporal, AutoGen, CrewAI and the provider SDKs
  15. Reference · 14Testing orchestration: transition coverage and fault injection
  16. Reference · 15Advanced: speculative execution, deadlocks, fairness and evaluating many agents
  17. Reference · 16The insurance lab: one quote workflow, end to end
  18. ReferenceGlossary
  19. AboutAbout this site and its sources
Reference · 16

The insurance lab: one quote workflow, end to end

The whole example in one place: the workflow, its states, the cases, a fixed pipeline next to a bounded agent loop, a crash, a pause for the underwriter, and the code that ran them.

What you will understand
The whole workflow
Eight steps, three agents, one person: who decides each next step, on one page.
Eighteen cases
Every case of the example with its route, status and the idea it teaches, and a lab to read any run in full.
Run it yourself
The commands, the files, and which function implements which concept of the site.

A broker's email arrives at nine in the morning. The client wants commercial property cover for a masonry warehouse built in 2012, sprinklered, roof eight years old, wind zone A. This is case UW-002, the straight path. By half past ten an underwriter has approved a recommendation that cites its evidence, and the run is complete.

Between the email and the approval, the quote workflow made about a dozen decisions about what runs next. Code made almost all of them. Three agents did work inside their steps. One person made the decision that counts. Every earlier page of this site explained one of those decisions in isolation. This page puts them back together on one case, then on all eighteen.

It is also the honest place to say what this is. The insurer, the broker, the cases, the rules, the fields, the roof-data provider, the timings and every number here are invented for teaching. This is an illustrative reconstruction, not a description of any real insurer or system, and nothing on this page reports the quality of a real model. The agents here are scripted stand-ins and time is simulated, so these results show how the orchestration works, not how good or how fast any model is.

1. The quote workflow, end to end#

The quote workflow is the name this site uses for the whole process from the broker's email to the underwriter's decision: the definition of the steps and the rules for what follows what. One execution of it, for one submission, is a run. Here is UW-002, the straight path, as the example prints it:

$ $PY run.py --case UW-002 --mode dag
Quote workflow · scripted stand-in agents (no model called) · simulated time · seed 7
UW-002 · Clean warehouse with a young roof · dag mode · run-1ef9 · trace e74ec7ad046e...
  path:      intake > gather_evidence > check_eligibility > draft_recommendation > verify_process > record_recommendation > await_underwriter > apply_decision
  fan-in:    roof_assessment ok [ok], guidance ok [ok], similar_decisions ok [ok]
  guard:     pass (Eligibility ran and every cited rule was retrieved.)
  recommendation: approve · cites - · missing - · policy 2026.2 · stored row status stored
  signal:    underwriter approve -> apply
  human_decision: {"decided_by": "underwriter", "decision": "approve", "override": false, "reason": "Clean submission; the recommendation and the evidence agree."}
  status:    completed · model calls 3 · tool calls 4 · simulated time 1.5 h (includes the wait for a person)
  expected:  as stated in the case
wrote 1 run file(s) in out/runs/ and out/summary.json

Each step on the path, with who does the work and who decides what comes next:

#StepWho does the workWho decides the next stepExplained on
1intakeintake agent: email to submissioncodeprimitives
2gather_evidenceassessment agent; three lookups in parallelcode: the fan-in ruleconcurrency, failures
3check_eligibilitycode: the rules of the policy fixturecodeprimitives
4draft_recommendationunderwriting agent, from a structured handoffcodehandoffs
5verify_processcode: the guardcode: pass, block or escalatecontrol plane
6record_recommendationcode: the idempotent writecodedurable workflows, limits
7await_underwriternobody: the run is suspendeda personhuman approvals
8apply_decisioncode: stores the human_decisioncode, from the person's signalhuman approvals

The policy fixture is the illustrative rule set the rules step applies: UW-GUIDE, version 2026.2, effective 2026-07-01, with an older version 2025.4 and this site's own 2026.3. Its rules are not insurance practice; the roof limits are invented. The policy version is the version a run used, recorded at the start and checked again when a decision arrives; UW-902 shows why. The underwriter cockpit is the web app where the underwriter reads the stored recommendation and decides; in the example the case file plays the cockpit and sends the decision.

Diagram: The quote workflow · who works and who decides, step by step

Each lane is one role. Left to right is time. Code (the orchestrator) decides what runs next at every step; the agents work inside their own steps; the underwriter decides at the end. A box crossing into another lane is a handoff. The agents are scripted stand-ins and time is simulated.

  1. Orchestrator (code)
    1. 3 check_eligibility: Deterministic rules of UW-GUIDE 2026.2. The same facts always give the same outcome.
    2. 5 verify_process: Checks that eligibility ran and every cited rule was retrieved, before anything is written.
    3. 6 record_recommendation: Stores the recommendation for the cockpit, with a key that makes a repeat store nothing new.
    4. 8 apply_decision: Written only from an applied signal of a person: role, decision, override, reason.
  2. Agents (stand-ins)
    1. 1 intake: The intake agent turns the broker's email into a submission record. From here on every step reads JSON.
    2. 2 gather_evidence: Three lookups in parallel; the fan-in rule decides what was enough.
    3. 4 draft_recommendation: Writes the recommendation from a structured handoff. The model recommends; a person decides.
  3. Underwriter (a person)
    1. 7 await_underwriter: The run waits with an approval token; the underwriter reads the recommendation in the cockpit.

2. Eighteen cases, one table#

The example has eighteen cases: UW-001 to UW-010 are shared by the whole series, UW-901 to UW-908 are this site's own. The runner plays each one in its own mode:

$ $PY run.py --all
Quote workflow · scripted stand-in agents (no model called) · simulated time · seed 7
case    mode  status     route         cites      human decision
UW-001  dag   suspended  decline       R-ROOF-01  -
UW-002  dag   completed  approve       -          underwriter: approve
UW-003  dag   suspended  request_info  R-ROOF-02  -
UW-004  dag   completed  escalate      R-ROOF-03  senior_underwriter: approve
UW-005  dag   completed  decline       R-ROOF-01  underwriter: decline
UW-006  dag   suspended  request_info  -          -
UW-007  dag   suspended  decline       R-ROOF-01  -
UW-008  loop  failed     decline       R-ROOF-01  -
UW-009  dag   completed  approve       -          underwriter: decline (override)
UW-010  loop  suspended  escalate      R-ROOF-03  -
UW-901  dag   suspended  escalate      R-ROOF-03  -
UW-902  dag   suspended  decline       R-ROOF-01  -
UW-903  dag   suspended  decline       R-ROOF-01  -
UW-904  loop  suspended  escalate      -          -
UW-905  dag   completed  approve       -          underwriter: approve
UW-906  dag   cancelled  approve       -          -
UW-907  dag   suspended  escalate      R-ROOF-01  -
UW-908  dag   suspended  request_info  -          -
wrote 18 run file(s) in out/runs/ and out/summary.json

A suspended status means the run is waiting for the underwriter: the case file sends no decision, so the run stops where a real one would wait. For UW-008 the route column shows the draft; nothing was stored, because the guard blocked. For UW-906 it shows the recommendation that was stored and then withdrawn.

CaseSituationWhat the orchestrator doesPage
UW-001Roof 31 years, zone CRules route to decline, cites R-ROOF-01; waits for the underwriterprimitives
UW-002Clean warehouse, roof 8 yearsStraight path, eight steps, one decisionthis page
UW-003Roof age unknownBranch to request_info, missing names the roof ageprimitives
UW-004Application 9 years, provider 22escalate under R-ROOF-03; only a senior underwriter may decideapprovals
UW-005An injected passage says "approve"Retrieved text is data; the route stays declinehandoffs
UW-006Roof provider times outRetry with attempt_number 2, then the fallback routefailures
UW-007A past approval under 2025.4decline under 2026.2; the old decision is not a reasonhandoffs
UW-008Loop skips the guidance searchThe guard blocks the write; the run failscontrol plane
UW-009The underwriter declines an approvehuman_decision with override true and a reasonapprovals
UW-010Input of UW-004, 20 trialsLoop paths vary, pipeline path never doesshapes
UW-901Process dies after step 2Resume from the checkpoint; finished steps not rerundurable
UW-902Policy moves to 2026.3 while waitingStale approval; back to the rulesapprovals
UW-903Optional lookup fails, one is slowPartial failure; the gap is reportedconcurrency
UW-904Loop keeps searchingBudget ends the loop; code escalateslimits
UW-905Decision arrives twiceApplied once; the repeat is acknowledgedapprovals
UW-906Broker withdraws after the writeCancellation with compensationdurable
UW-907Draft disagrees with the rules at a boundaryThe guard escalatescontrol plane
UW-908Roof provider fails run after runThe circuit breaker opens; fallback without callingfailures

The lab below opens any case's run in full: the path through the steps, the events, the attempts, the final status, the recommendation and the human decision.

The table above is the same information for a reader without JavaScript; the full event log of any case is printed by run.py --case UW-00N --verbose.

3. The same task as a pipeline and as a bounded loop#

The site's recommended design, stated as a design, is the hybrid: a deterministic skeleton, a model's choice only inside one bounded step, a code guard at the exit of that step, and a person at the decision. The example runs the same task both ways. In pipeline mode (--mode dag) code decides every next step. In loop mode (--mode loop) steps 2 to 4 become one agent loop in which the stand-in model picks the next tool inside a budget; steps 5 to 8 stay fixed code.

UW-010 runs the input of UW-004 twenty times in each mode:

$ $PY run.py --case UW-010 --mode loop --trials 20
Quote workflow · scripted stand-in agents (no model called) · simulated time · seed 7
UW-010 · loop mode · 20 trials · 9 distinct path(s)
  status: suspended 19, failed 1 · route: escalate 20 · calls per run: 8 to 13
  x4  get_roof_assessment > search_guidance > check_eligibility > finish
  x4  search_guidance > get_roof_assessment > find_similar_decisions > check_eligibility > finish
  x2  find_similar_decisions > search_guidance > get_roof_assessment > check_eligibility > finish
  x2  find_similar_decisions > get_roof_assessment > search_guidance > check_eligibility > finish
  x2  get_roof_assessment > search_guidance > find_similar_decisions > check_eligibility > finish
  x2  search_guidance > get_roof_assessment > check_eligibility > finish
  x2  get_roof_assessment > find_similar_decisions > search_guidance > check_eligibility > finish
  x1  find_similar_decisions > get_roof_assessment > search_guidance > search_guidance > check_eligibility > finish
  x1  get_roof_assessment > find_similar_decisions > check_eligibility > finish
wrote 20 run file(s) in out/runs/ and out/summary.json
$ $PY run.py --case UW-010 --mode dag --trials 20
Quote workflow · scripted stand-in agents (no model called) · simulated time · seed 7
UW-010 · dag mode · 20 trials · 1 distinct path(s)
  status: suspended 20 · route: escalate 20 · calls per run: 7 to 7
wrote 20 run file(s) in out/runs/ and out/summary.json

Nine paths against one. Calls per run from 8 to 13 against always 7. One trial in loop mode skipped the guidance search, and the guard stopped it before the write. The model's freedom bought nothing in this case and cost calls and one failed run; the guard is what kept that failure safe. Whether freedom pays in another task is a question for the control plane page and for evaluation.

ModeDistinct paths in 20 trialsCalls per runRouteStatus
pipeline (dag)17escalate 20suspended 20
loop (turn budget 6)98 to 13escalate 20suspended 19, failed 1 (guard)

4. The pause, the crash and the fan-out#

Three mechanisms carry most of the production risk, and each has its own page and lab. Here they are on one run each.

The pause. UW-004 suspends after the write with an approval token, waits 180 simulated minutes, and resumes only when a senior underwriter's signal passes five checks (used token, run waiting, token match, role, policy version); an underwriter who is not senior gets reject_role and the run keeps waiting. The lab opens on UW-902 and lets you play the underwriter and switch on the accidents: the policy changes while waiting, the decision arrives twice, the process restarts.

Your action and accidentWhat the orchestrator does
Approve, nothing goes wrongapply; run completed
The same click twicefirst apply, then ignore_duplicate
Approve after the policy moved to 2026.3recheck_eligibility: back to the rules, new wait
Process restarts during the waitthe waiting record is read back from the checkpoint; nothing is lost

The crash. UW-901 dies after step 2; a second process reads the checkpoint, continues with step 3, and makes the same 4 tool calls as a run without a crash. If it dies after the write and before its checkpoint, the idempotency key keeps the store at one row. See durable workflows.

The fan-out. Step 2 runs the three lookups on three workers with a deadline; the fan-in rule says the roof assessment and the guidance are required and similar decisions optional.

LookupsFan-inRoute
all ok (UW-002)all aggregatednormal
roof times out twice (UW-006)required missingrequest_info, missing roof_assessment
similar fails, guidance slow (UW-903)optional missing, reportednormal
roof skipped, breaker open (UW-908)required missingrequest_info, without calling the provider

5. The person at the end#

An override is a human decision that goes against an approve or decline recommendation. In UW-009 the stand-in recommends approve; the underwriter declines because the broker's loss run shows an open water damage claim that is not on the application. The human_decision records the role, the decision, override true and that reason. The reason is information the agents never had.

That is the shape of the whole site in one record. The orchestrator decided what ran next, eight times. Three agents did bounded work. Code checked everything that could be checked. And the decision that matters was made by a person, who could see the evidence, the rules and the gaps, and who was free to disagree.

What this is not. This page runs the orchestration of one synthetic workflow. Measuring how often a real model's recommendations are right is the subject of Eval Engineering; the runtime around each model call is Harness Engineering; the messages between agents are Agent Communication.

6. The same workflow in a coding agent#

The quote workflow is one instance of a general shape. A coding agent that fixes an issue follows the same moves, with different nouns:

IdeaQuote workflowCoding agent
Sequenceintake, evidence, rules, draft, guard, writeplan, edit, test, pull request
Branchthe fan-in rule; the guard's verdicttests pass or fail
Loopbounded agent loop in loop modeedit and test again
Fan-outthree lookups in parallelCI jobs in parallel
Human approvalthe underwriter in the cockpitthe reviewer approves the merge
Durable statecheckpoints, the stored recommendationthe branch and the pull request
Budgetturns, tool calls, tokens, timeturn limit

The loop inside one coding agent is covered on Harness Engineering; hooks, review and CI on Diff to Deploy.

7. Run it yourself#

The example is standard-library Python 3, in examples/uw-orchestrator/ of this site's repository. No model is called, there is no key and no network.

cd examples/uw-orchestrator
PY=/opt/homebrew/bin/python3
$PY -m unittest                                          # 45 tests
$PY run.py --all                                         # every case in its own mode
$PY run.py --case UW-006 --verbose                       # with the event log
$PY run.py --case UW-901 --crash-after gather_evidence   # the process dies; prints the run_id
$PY run.py --case UW-010 --mode loop --trials 20         # the path varies

Where each idea of the site lives in the code:

ConceptFile and function
The orchestrator (what runs next)engine.py:Engine.advance
Transitions and their legalitycore.py:RUN_TRANSITIONS, run_transition
Pipeline and loop modesworkflow.py:build_workflow, step_agent_loop
Fan-out and fan-incore.py:simulate_fanout, fan_in
The guardcore.py:verify_process, workflow.py:step_verify_process
Permissions and budgetstools_sim.py:TOOL_PERMISSIONS, core.py:budget_check
Suspend and resumeengine.py:Engine.suspend, Engine.signal; core.py:accept_resume
Checkpoint, idempotency, compensationengine.py:Engine.checkpoint, RecordStore.put_recommendation; workflow.py:compensate_record
Circuit breakercore.py:breaker_before_call, breaker_after_call
One trace per runengine.py:make_trace_id, Engine.add_span, Engine.break_trace
Outcome checkrun.py:check_expected

The README in that folder has the full case table, real output of every command, and a longer concept table.

Checklist#

In one breath#

The quote workflow turns a broker's email into a recommendation an underwriter can decide on, in eight steps. Code decides what runs next at every step; three agents do bounded work inside theirs; a guard checks the draft before the write; and the run waits, holding nothing, until a person decides. Eighteen synthetic cases exercise every path, from the straight approval to a crash, a stale approval, a runaway loop and a broken provider.

Where to go from here#

You have seen the whole site in one place. To go deeper on any mechanism, follow the page links in the tables above. To see where this site's subject ends and a sister site's begins, read About, which also lists the sources and what this site proposes as its own design.