101-04 — Debug a failure

Two intentional Err paths: bad JSON from fake_chat and schema-invalid inputs—still fully offline.

Updated

What you will build

Two intentional Err paths: bad JSON from fake_chat and schema-invalid inputs—still fully offline.

Prerequisites

Files you will touch

None (inline Python only).

Step 1 — Invalid JSON from fake chat

Reuse the 101-02 scaffold but return ChatResult(True, "{not json") from fake_chat. Run runner.run with the same valid input dict as before.

Expected: Err describing parse / LLM failure (exact type varies by task plumbing).

Step 2 — Schema mismatch input

Keep fake_chat valid JSON, but call runner.run("pw_chunk_classify", "v1", {}) (empty dict).

Expected: Err tied to missing required fields per input_schema.

Step 3 — Read the error surface

Expected output

  • Step 1 yields an Err from malformed assistant JSON (offline).
  • Step 2 yields an Err listing missing required input_schema keys.
  • You can name whether each failure is primarily parse vs schema layer.

Common failures

Mistake Symptom
Assuming all Err stringify the same Inspect types / attributes on Result

Verify

You can explain which layer failed (parse vs schema) for each experiment.

What changed

You trust Ok/Err as first-class outcomes—not exceptions—for governed tasks.

Next step

Continue to Tutorial 201 when you need to author tasks, sidecars, operators, and RAG patterns.