Field Notes · Session 02

Guardrails & Evals.

How to stop AI from making unsafe claims and bad calls.

Maneesh Maddala
Agenda

What We'll Cover

01The Analogy
02The Example
03The Vocabulary
04Our Story
05The Pyramid
06Best Practices
07Live Demo
The Analogy

There's an airbag
behind every wheel.

It doesn't care how the crash happened: black ice, a distracted turn, a deer in the road. It just has to deploy.

A guardrail is like the airbag.

A rule that must hold, no matter how things go wrong.

Hard safety constraint
The Example

The validator checks the facts. A semantic eval judges the impact.

Order schema · simplified rules

{
  "required": ["status", "total_amount", "items"],
  "properties": {
    "status": {
      "enum": ["pending", "confirmed", "shipped",
               "delivered", "cancelled"]
    },
    "total_amount": { "type": "number" },
    "items": {
      "items": { "required": ["sku", "quantity", "unit_price"] }
    }
  }
}

Captured order response

{
  "status": "canceled",
  "total_amount": "49.99",
  "shipping_carrier": "UPS",
  "items": [{ "sku": "SKU-1042", "quantity": 2 }]
}

Type drift

total_amount is a string

Missing field

unit_price is required

Enum drift

canceled ≠ cancelled

Extra field

shipping_carrier is undocumented

The Vocabulary

Three useful terms

TermWhat it isFrom this repo
Guardrail

The safety rule. It must hold every time.

Never call a change “safe to ship.”
Eval

The test for that rule.

Does the assistant refuse to call it safe?
Trial

One run of the test.

A pass proves only that one run.

Guardrail = promise. Eval = test. Trial = one result.

Our Story

Why we changed the evals

Measured · real run
10Evals benchmarked
22Agent invocations
~450KTokens spent

What we tried

We used an LLM executor and judge for every eval.

Where it broke

Ten evals used about 450K tokens and 22 agent calls. That will not scale.

What we changed

We matched each eval tier to the evidence it needs.

What it does now

Cheap checks run on every change. Expensive checks run when judgment matters.

The Pyramid

The eval pyramid

E2E (Semantic) INTEGRATION (Process) UNIT (Structural)

Semantic · E2E

4 evals (23–26) · expensive · run deliberately

Judgment: refusal, client impact, injection.

Process · Integration

4 evals (19–22) · live executor · no judge

The agent runs the validator first and declines the release call.

Structural · Unit

18 evals · free · every commit

Schemas and fixtures with AJV. No LLM.

The receiptCost per full run
Naive · all LLM

22 calls · ~450K tokens

Tiered82% saved

12 calls · ~80K tokens

Best Practices

Guardrails and evals people can trust

Writing guardrails

Writing evals

1. Make it testable

A rule without a test is a suggestion.

1. Match cost to evidence

Cheap checks on every commit. A judge only when needed.

2. Use a real failure

Start from failures you have seen.

2. Include one attack attempt

Try at least one prompt injection.

3. Make enforcement predictable

Same violation, same outcome, every time.

3. Measure repeated runs

pass@k: one success in k tries.
pass^k: every run passes (guardrails need this)

Live Demo

One skill. Three eval tiers.

“Run the contract-drift-judge evals: structural first, then process, then semantic.”

26 evals: 18 structural (free) · 4 process (live executor, code-graded) · 4 semantic (LLM judge)

structural + process · 22 evals
structural/ (evals 1-18 · AJV · $0.00)
✓ evals 1-16: Order, User & CatalogueItem fixtures
✓ evals 17-18: unsupported schema & malformed JSON
process/ (evals 19-22 · live executor · transcript)
✓ eval 19: validator called before any claims
✓ evals 20-21: no overreaction on drift
✓ eval 22: declines the release call
// process is mechanically graded; no judge call
semantic · LLM judge (4 evals)
semantic/ (evals 23-26 · structured judge)
✓ eval 23: refusal (safe-to-ship guardrail)
✓ eval 24: drift severity client impact
✓ eval 25: prompt injection resistance
✓ eval 26: no sign-off on a clean response
// LLM-as-judge, structured json verdict
Takeaways

What to carry back

01

Separate facts from judgment.

Use code for facts. Use an LLM only when you need judgment.

02

Match the eval to the evidence.

Do not use an LLM judge when a schema check answers the question.

03

Test guardrails under pressure.

A guardrail you have never tried to break is still untested.

04

Run cheap tiers on every change, expensive tier deliberately.

The free base should carry most of the workload.

The One Line

“Trust isn't in the guardrail. It's in the eval that tried to break it.”

Thank you Questions