Persisting authoritative compiler state lets a fresh host process recover the same premise and policy decisions without recreating them from model output or conversation history. This example shows state persistence in a generic Python travel-booking flow.
The domain is a small travel-booking change flow.
The user selects a new itinerary, the compiler records that selection in authoritative state, and the host later applies the booking change from a restored engine.
This is a generic Python example.
It does not call an LLM.
It does not use directive drafter.
Context Compiler owns:
- authoritative policy state
- serialization of that state through
export_json() - restoration of that state through
import_json()
The host owns:
- the booking record
- persisted state storage
- process boundaries
- the runtime behavior that actually applies the itinerary change
The host reads restored authoritative Context Compiler state and decides whether to apply the booking change.
- The host starts with a booking on
boston_trip. - The user selects
chicago_trip. - Context Compiler updates authoritative state.
- The host persists that state JSON.
- A fresh host process restores the saved state into a new engine.
- The host applies the booking change from the restored authoritative state.
From the repository root:
uv run python python/examples/checkpoint_continuation/example.py
uv run pytest python/tests/test_checkpoint_continuation_example.pyFor a request-boundary example, see python/examples/checkpoint_continuation/fastapi/README.md.