ontoloji.orgOpen Reference Hub
Verification & Security12 min read·Updated: 2026-12-03·Türkçe sürüm →

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.

Executive Summary — Key Takeaways
  • 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.
Generate-Evaluate-Repair Pipeline & Widened-Grammar Attack Discipline
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.
Ground Programmatic Graders in Your Enterprise Ontology

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

Open License (CC BY 4.0) · Cite This Page

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)

More Guides in This Series

Core Architecture
How AI Uses an Ontology
9 min read
Agent Engineering
Agent Harness vs. Ontology
8 min read
Data Engineering
ERP, CRM & MES Patterns
10 min read
Strategy & Governance
30-Day Ontology Strategy
7 min read
ERP Integration
ERP Ontology Integration Guide
11 min read
ERP Data Engineering
Logo Tiger, Nebim V3 & Turkish Unicode Traps
14 min read
Agent Governance
Adversarial Verification, Permissions & Compaction
13 min read
Verification Engineering
Absence-Aware Gates & Ratio Reconstruction
13 min read
Provenance & Governance
Draft vs. Normative Provenance Hygiene
12 min read
SAP & Protocol Architecture
SAP BTP, Cloud Connector & ORD Ontology
11 min read
ERP Write-Safety
Logo REST, Nebim Integrator & UBL-TR Safety
12 min read
Platform Architecture Comparison
Cortex, Genie, dbt & Cube vs. Ontology
12 min read
Systems Engineering & Forensics
ERP Integrator Anti-Patterns & Forensics
13 min read
Platform Architecture Comparison
Fabric IQ, D365 MCP & SAP Joule vs. Ontology
12 min read
Retrieval & RAG Architecture
PageIndex Vectorless Tree RAG vs. Vector DBs
11 min read
Platform Architecture Comparison
Atlan, Stardog & Neo4j vs. Ontology
12 min read
Statutory & Financial Governance
GİB UBL-TR, VUK/TMS 29 & KVKK Ontology
13 min read
Agent Memory & Ontology Architecture
Cognee & Zep Graphiti vs. Ontology
11 min read
Protocol & Multi-Agent Architecture
MCP vs. OpenAPI & Specialist Agents
12 min read
Protocols & Standards
MCP 2026-07-28: Tasks, Events & Apps
13 min read
Agent Architecture & Governance
Agent Harness Engineering Rubric
12 min read
Agent Architecture & Governance
Multi-Agent Task Boards & Mailboxes
12 min read
Verification & Security
NSA MCP Security & CIMD vs. DCR
13 min read
Agent Architecture & Governance
OpenTelemetry for AI Agents & MCP
11 min read