Engineering

Reference Oracle Implementation

Give the agent an oracle, not a pep talk.

Use when

You need a coding agent to implement complex behavior that can be checked against a browser, official library, legacy system, API, compiler, or production output.

difficultyAdvanced
categoryEngineering
sourceAdapted from public agentic-loop case studies

Cadence

Before implementing tricky behavior with an external source of truth

Verification

Generated outputs match the reference oracle across the agreed fixture set, with tolerances documented for legitimate differences.

Structured loop spec

FieldValue
NameReference Oracle Implementation
CategoryEngineering
TriggerBefore implementing tricky behavior with an external source of truth
ObjectiveGive the agent an oracle, not a pep talk.
Allowed inputsRelevant files, source notes, logs, tests, screenshots, metrics, or task state for this loop
Allowed actionsIdentify the most trustworthy reference output: browser engine, legacy implementation, official API, golden files, or production traces.; Build a small command or fixture harness that compares the new implementation against that oracle.; Start with the simplest passing cases, then add one behavior class at a time.; After each change, run the parity harness and record failures with inputs, expected output, actual output, and tolerance rules.; Stop when the scoped fixture set passes or the remaining differences require product or standards judgment.
VerificationGenerated outputs match the reference oracle across the agreed fixture set, with tolerances documented for legitimate differences.
Stop conditionStop when the verifier passes, the budget is exhausted, no progress is made, a blocker appears, or approval is required.
BudgetSet a time, turn, token, retry, file, or dollar cap before running the loop.
Approval boundaryHuman approval required before publishing, sending, deleting, spending, changing accounts, touching production, or making reputational/legal/financial commitments.
Safe outputPull request, patch, report, or evidence log
Works withClaude Code, OpenAI Codex, Cursor, Gemini CLI, any tool-using coding agent

Steps

  1. Identify the most trustworthy reference output: browser engine, legacy implementation, official API, golden files, or production traces.
  2. Build a small command or fixture harness that compares the new implementation against that oracle.
  3. Start with the simplest passing cases, then add one behavior class at a time.
  4. After each change, run the parity harness and record failures with inputs, expected output, actual output, and tolerance rules.
  5. Stop when the scoped fixture set passes or the remaining differences require product or standards judgment.

Prompt

Run the Reference Oracle Implementation loop. First identify the reference oracle for the behavior: browser engine, legacy system, official library, API response, compiler output, or golden files. Build a repeatable parity harness before implementation. Add one behavior class at a time, compare expected vs actual output, document any tolerance rules, and stop when the scoped fixture set passes or remaining differences require human judgment.

Run in Claude Code

Paste this into Claude Code (or any tool-using agent) to run the loop bounded: one change per round, the same verification every round, durable state files, and explicit stop conditions.

Run the "Reference Oracle Implementation" loop from AI Loop Library (https://ailooplibrary.com/loops/reference-oracle-implementation/) as a bounded loop.
Goal: Give the agent an oracle, not a pep talk.
Rules: one change per round; run the same verification every round (Generated outputs match the reference oracle across the agreed fixture set, with tolerances documented for legitimate differences.); append each round to docs/loops/reference-oracle-implementation/progress.md and update docs/loops/reference-oracle-implementation/state.json; stop on verifier pass, 8 rounds, 3 consecutive failed verifications, no progress, a blocker, or anything needing human approval (money, production, outbound, deletion). Finish with a proof report: rounds used, changes made, verification output, remaining risk, and the next human decision.

Get the MCP server + agent pack

Tags

reference implementationtestingparityagent coding

Related loops

Browse all 68 loops