Purpose
The Warranty Claim example reviews one claim from a customer statement, a product photo, and a receipt reference. It shows the complete authoring, model, and result-contract feature group in one business flow.
Features
The example proves these behaviors:
- The Elixir DSL and YAML document compile to the same semantic agent spec.
- A typed public context selects the tenant and plan instructions.
- Typed text, image, and document parts enter the model prompt.
- A transient primary-model failure retries once and then uses a fallback.
- An invalid confidence value causes one bounded result-repair pass.
- The final value conforms to the warranty result schema.
- The response includes typed text and document parts.
- Public reports show media metadata, but do not show media bytes or file IDs.
The scripted model makes the failure and repair paths repeatable. It does not use a provider key, network request, or recorded provider response.
Read It In This Order
lib/agent.ex- the code-first context and result contracts.agent.yaml- the equivalent data-defined agent.lib/instructions.ex- request-time tenant policy.lib/scenario.ex- media input and model-policy wiring.test/warranty_claim_triage_test.exs- application behavior and runtime guarantees.warranty_claim.livemd- the guided contract walkthrough.
The agent, YAML definition, schemas, and instruction provider are application
patterns. ScriptedLLM, scenario.ex, example.exs, the manifest, and the
tests are deterministic demo code. A production application supplies real
provider credentials and keeps the same model-policy and result contracts.
Run It
Run the command demo:
mix run examples/warranty_claim/example.exs
mix test --only example:warranty_claim
Run the scenario tests:
mix test examples/warranty_claim/test/warranty_claim_triage_test.exs --trace
Run one feature through its native ExUnit tag:
mix test --only structured_results
Open warranty_claim.livemd for the executable walkthrough.
Important Files
lib/agent.exdefines the code-first agent and both Zoi schemas.agent.yamldefines the equivalent data-authored agent.lib/instructions.exresolves the tenant policy from public context.lib/scripted_llm.excauses deterministic retry, fallback, and repair.lib/scenario.exbuilds the multimodal claim and produces a safe report.example.exsis the small command entry point.test/warranty_claim_triage_test.exsis the behavior authority.
Expected Result
The command prints one repaired, schema-valid warranty decision. It also shows authoring parity, fallback model use, and the number of result-repair passes.
Next Guide
For the public contracts, read these guides: