15 seconds

The UI got a poem.

The model apologized in prose instead of returning {"answer", "citations"}. The panel crashed.

ModelRaw textValidateJSON schemaUITyped fields
Lesson notesJSON or nothing: the short version+

Week 5 · LLM gateways · about 3 minutes

What you will be able to do

Enforce a schema on model output for Helix, then retry once when the JSON is invalid.

The idea

Downstream code needs a contract: answer text and citation IDs, not free prose. Validate against a schema. On failure, retry once with the error — then fail closed.

Structured output modes help, but you still validate. Trust the parser, not the model's manners.

import json

REQUIRED = {"answer", "citations"}

def parse_or_raise(text: str) -> dict:
    data = json.loads(text)
    if not REQUIRED.issubset(data):
        raise ValueError("schema")
    return data

If it is not valid JSON for your schema, it is not an answer.

Key takeaways

  • Define required fields up front.
  • Validate every completion.
  • Retry once on schema failure; then fail closed.

Part of the Forward Deployed Engineer roadmap. New to the role? Start with what a Forward Deployed Engineer does.