QuoteGraph tutorial
QuoteGraph is a guided car-insurance quote, not a toy conversation. It collects a driver,
a catalogued vehicle, insurance history, and coverage choices; produces deterministic quote
tiers; supports a coverage revision; and completes only after the customer accepts a current
tier. The implementation lives in
ezgraph-demo.
What this tutorial covers
DriverNode → VehicleNode → HistoryNode → CoverageNode → QuoteNode ──accept_quote──→ finish()
↑ │
└── revise_coverage
Any conversational node ──terminate_session──→ TerminateSessionNode → END
Every conversational node owns the durable facts it validates. CoverageNode calls the
deterministic rating engine and seeds QuoteNode with its result; the model never calculates
a premium or invents an accepted tier. Accepting a tier completes the graph directly with
finish(...); TerminateSessionNode handles only a customer’s request to stop.
| Node | Owns | Demonstrates |
|---|---|---|
DriverNode |
identity and licence facts | schema plus calendar, age, and licence validation |
VehicleNode |
resolved catalog ID and vehicle use | lookup before capture and trim disambiguation |
HistoryNode |
current insurance and recent incidents | an isolated incident-history space |
CoverageNode |
chosen coverage | deterministic pricing and atomic target state |
QuoteNode |
current tiers and acceptance | code-rendered revisions, a backward route, and completion |
The seven lessons
- A fifteen-turn live replay — the complete recorded quote, including corrections, repricing, and acceptance.
- Graph and state ownership — register the graph and make node channels explicit.
- Validated collection and catalog lookup — use schemas as an interface, then enforce the real business rule in code.
- Session lifetime and history spaces — isolate the incident and presentation conversations, and expire an old quote safely.
- Deterministic rating — keep pricing and coverage constraints out of model prose.
- Revisions, direct responses, and acceptance — recalculate, go back, or finish only from current state.
- Testing the whole quote — distinguish unit coverage from the credential-conditional semantic conversation.
Running it
cd ezgraph-demo
npm run test:quote-graph
npm run test2:quote-graph
The first command runs the deterministic suite with scripted model replies; the provider-backed
E2E file it also matches is skipped without USE_ENV=1. The second script sets
USE_ENV=1 KEEP_SESSION=1, runs the fifteen-turn semantic scenario against the configured
model provider, and retains its session for inspection.
Next
Start with 1. A fifteen-turn live replay.