Skip to course content
Free LangChain course

LangChain for LLM Applications and RAG

Module 03 Activity

Scenario

The next step after your model call is code, not a person. Everything here is about making the boundary safe.

What you build

A parser with format instructions, a validating schema, a feedback-driven retry with a give-up path, and a schema-change plan.

Steps

  1. Replace prose output with a parser, binding the format instructions with .partial() so they cannot be forgotten.
  2. Run four candidate outputs through the parser, including JSON wrapped in prose and truncated JSON. Note which succeed.
  3. Add a validating schema constraining types, allowed values and at least one format pattern.
  4. Build a retry that feeds the specific error back, caps attempts, and has an explicit give-up path.
  5. Count parse failures separately from validation failures and alert on each rate.
  6. Write the schema-change plan: which changes are backward compatible and what your rolling-deploy order is.

Evidence to hand in

Review checklist