Purpose
The Durable Refund Agent demonstrates the execution and continuation feature group with one deterministic business flow. It does not use a provider key, network request, or recorded model response.
Features
The eight deterministic demonstrations show:
- one asynchronous request with thinking and content deltas;
- two read-only operations that finish in reverse order but stay in model order;
- typed cooperative cancellation with one terminal event;
- model-turn, output-token, and capability-time limits;
- worker crash recovery after an unsafe refund result is durable;
- data-only replay plus an independent runnable fork with root and parent lineage.
- normalized token and cost usage plus a redacted local trace sink;
- one supervised process-hosted agent with stable lookup and terminal state.
The crash case stops the first worker after the refund result reaches the
session store but before the worker can acknowledge it. A second worker takes
the expired lease, resumes the stored snapshot, and uses the result without
calling issue_refund again.
Read It In This Order
lib/agent.ex- the agent limits and unsafe-once refund operation.lib/actions/issue_refund.ex- the external effect boundary.lib/scenarios/async_execution.ex- streaming and cancellation.lib/scenarios/parallel_operations.ex- bounded parallel tool calls and ordered observations.lib/scenarios/execution_limits.ex- turn, token, and timeout limits.lib/scenarios/durable_recovery.ex- checkpoint, lease, and recovery behavior.lib/scenarios/safe_fork.ex- data-only replay and independent session branches.lib/scenarios/observability.ex- usage, trace projection, and redaction.lib/scenarios/process_host.ex- supervised process hosting.test/execution_and_continuation_test.exs- application behavior and runtime guarantees.durable_refund.livemd- the guided runtime walkthrough.
The agent, action, control, limits, and store interfaces are application
patterns. ScriptedLLM, the scenario modules, example.exs, the manifest, and
the tests are deterministic demo code. Production code uses a real model and a
durable store, but the same cancellation, recovery, and fork APIs apply.
Run It
mix run examples/durable_refund/example.exs
mix test --only example:durable_refund
mix test examples/durable_refund/test/execution_and_continuation_test.exs --trace
mix run scripts/check_livebooks.exs -- --project examples/durable_refund/durable_refund.livemd
Open durable_refund.livemd for the complete executable walkthrough.
Important Files
lib/agent.exdefines the refund agent and its execution limits.lib/actions/issue_refund.exis the unsafe-once operation.lib/controls/allow_refund.exmakes the unsafe operation policy explicit.lib/scripted_llm.exprovides deterministic stream, cancel, and refund paths.lib/scenario.exgives callers one stable entry point.lib/scenarios/separates the six runtime demonstrations by concept.example.exsis the small command entry point.test/execution_and_continuation_test.exsis the behavior authority.
Expected Result
The command prints evidence for streaming, stable parallel result order, cancellation, execution limits, crash recovery, replay, and a safe fork. It also prints local trace, usage, and process-host evidence.
Next Guide
For the public contracts, see: