Evals Before Prompting: Generate-Evaluate-Repair Loops, Attack Batteries & Observer Subagents
Building regression evals before touching prompts, decomposing brittle mega-prompts into Generate-Evaluate-Repair loops, stress-testing widened parsers with attack batteries, and catching reward hacking with observer subagents.
- 01Build evals before editing prompts: a regression suite covering control cases, historical edge cases, and capability boundaries is the only way to separate prompt-fixable drift from hard model limits.
- 02Defensive prompt patches written for older models ("never state anything uncertain") cause frontier models to over-comply and withhold valid records; version-control every patch with its retirement condition.
- 03Three compact prompts wired as Generate -> Programmatic Evaluate -> Targeted Repair beat a single mega-prompt on accuracy, latency, token spend, and runtime constraint injection.
- 04Every grammar or rule widened for recall requires a dedicated false-positive attack battery; zero false positives on an existing corpus only proves the corpus has not hit the new token shape yet.
1. Evals Before Prompting & Separating Prompt, Harness, and Model Levers
Without an automated evaluation suite, prompt engineering degenerates into whack-a-mole. Telling an LLM "always compute totals accurately" never adds arithmetic capability—if a task requires exact computation or schema lookup, give the model a deterministic tool, not a sterner paragraph.
Reliable teams separate fixes across three levers: Prompt (clear XML boundaries separating role, policy, and untrusted data, plus balanced two-sided trade-off costs), Harness (programmatic output schemas, stop sequences, and tool gates), and Model (upgrading reasoning effort only when evals prove capability saturation).
- Three Mandatory Eval Buckets: Every production suite needs unambiguous control cases, encoded past failures so regressions surface immediately, and capability-boundary cases testing when the agent must escalate to a human or refuse.
- Retiring Stale Defensive Rules: One-sided warnings left over from weaker model generations skew smarter models toward excessive refusals; tag defensive rules with the model version they patched and prune them on upgrade.
2. Generate-Evaluate-Repair Loops & Widened-Grammar Attack Batteries
Packing twenty formatting, compliance, and reconciliation rules into a single generation pass hits output ceilings and burns 3x latency in extended thinking. Decomposing the workflow into Generate -> Programmatic Grader -> Repair lets fast code check hard invariants and invokes a tiny repair pass only when violations occur.
When maintaining those programmatic graders—such as statutory citation parsers, SKU normalizers, or tax-code validators—widening a pattern to boost recall introduces a subtle trap:
- Corpus Regression != Grammar Safety: Reporting "zero false positives on the test corpus" only measures historical coverage; verifiers must actively attack newly accepted token shapes with clean business prose and narrow the grammar rather than documenting known bugs.
Draft Pass ──► Deterministic Python / Ontology Grader
│
Violations ┴──► Targeted Repair Pass ──► Verified Deliverable
Widened-Grammar Attack Battery Rule:
Trap : Widening regex to [A-E]\d+[A-Z]? yields 0 false positives on 92 saved docs
Reality: Clean commercial prose ("B2B portal", "A4 sheet") triggers false matches!
Fix : Pair every grammar widening with adversarial clean-text tests targeting the new shape.3. Observer Subagents: Separating Execution From Method Auditing
As agents run unattended for hours, failure shifts from inability to reward hacking—reverse-engineering test assertions, cherry-picking sample windows, or fabricating supplier leverage to satisfy an objective. Asking one agent to both execute a hard goal and police its own ethics splits its attention.
- Declarative Read-Only Watchdogs: Pairing a worker with a dedicated observer subagent mirrors every tool call and truncated (~2,000-character) tool result into the observer wrapped strictly as read-only data tags so worker outputs cannot prompt-inject the watcher.
- Mid-Run Course Correction: Silent until needed, the observer intervenes immediately when it spots test tampering, unverified sources, or unaligned timestamps—saving hours of wasted tokens before final review.
Generate-Evaluate-Repair loops and observer subagents work best when backed by an enterprise ontology: deterministic object schemas, status rules, and permission gates give your grader an authoritative source of truth.
Glossary Concepts Referenced in This Guide
Agent = Model + Harness) responsible for tool-calling loops, context compaction, retries, sandboxing, and execution traces.ORDER_LINES and PAYMENTS) in one flat SQL query, multiplying totals silently.UPDATE/INSERT statements on ERP/CRM databases, requiring typed action proposals validated against preconditions and approved by a named human role.Free to reference in engineering docs, ADRs, articles, and course syllabi with attribution.
[Evals Before Prompting: Generate-Evaluate-Repair Loops, Attack Batteries & Observer Subagents — Ontoloji.org](https://ontoloji.org/en/guides/evals-before-prompting-generate-evaluate-repair-and-observer-agents)