Skip to main content
The NLSpec Conformance pattern gives an agent a detailed specification document, has it build an implementation, and then loops on automated conformance tests until the implementation achieves full conformance. This is the same pattern used by benchmarks like AttractorBench to measure how well agents follow complex specs.

When to use this

  • You have a detailed specification (API contract, RFC, design doc) and want an agent to implement it
  • You have automated tests that can verify conformance
  • The implementation is too large to get right in one pass and benefits from iterative repair

The workflow

NLSpec Conformance workflow: Start → Plan → Implement → Quick Tests → Quick passing? → Full Tests → All passing? → Exit, with Fix Failures loop
n-l-spec-conformance.fabro

How it works

Spec reading and planning

The plan node reads the specification and produces an implementation plan. Because the spec may be long (thousands of lines), the prompt tells the agent to read it from a file rather than trying to include it inline:

Implementation with a shared thread

The implement and fix nodes share a thread_id="impl", so they accumulate context across loop iterations. When the agent returns to fix after a failed conformance run, it sees the full history of what it built and what broke. Combined with fidelity="full", the agent retains the detail it needs to make targeted repairs.

The conformance loop

The core of this pattern is the test-fix loop:
The quick conformance suite runs a subset of tests that execute fast (seconds, not minutes). The agent iterates against this subset first, fixing one failure class at a time. Only after the quick suite passes does it run the full conformance suite. This two-tier approach mirrors how developers work: run the fast tests while iterating, then run the complete suite before calling it done.

Fix node prompt

The fix prompt reads conformance output and targets specific failures:

Max visits as a safety valve

max_visits=5 on the fix node prevents infinite loops. If the agent can’t pass in 5 iterations, the workflow moves on with the best result so far. Tune this based on spec complexity: a 30-line spec might need 2 iterations, a 2,000-line spec might need 10.

Goal gate on full conformance

The test_full node has goal_gate=true. If the full conformance suite never passes, the workflow is marked as failed even if execution reaches the exit node. This makes the workflow’s success criteria explicit: partial conformance is not a passing result.

Model assignment

The model_stylesheet assigns a cheaper model as the default and routes implementation work to a more capable model:
The .impl class targets both the implement and fix nodes (both have class="impl"). Planning and implementation get the stronger model with high reasoning effort; any lightweight nodes you add later (summaries, notifications) default to the faster model.

Adding a human approval gate

For high-stakes specs, add a human gate after planning:
The agent writes its plan to plan.md, the human reviews it, and either approves (proceeding to implementation) or sends it back for revision.

Adapting for your project

To use this pattern:
  1. Write your spec as a Markdown file in the repo (e.g. docs/spec.md)
  2. Write conformance tests that exercise the spec’s requirements via a CLI or test runner. Split them into quick (core paths) and full (everything) suites.
  3. Wire the Makefile so make conformance-quick and make conformance-full run the suites and output results
  4. Customize the prompts to reference your spec file, your project’s language and conventions, and your conformance contract
The pattern works for any spec that has automated verification: API contracts with integration tests, protocol implementations with compliance suites, or library specs with unit tests.

What you’ve learned

  • The conformance loop (implement, test, fix, repeat) is the core pattern for spec-driven development
  • Two-tier conformance (quick then full) keeps iteration fast
  • Shared threads (thread_id) give the fix node context from prior iterations
  • max_visits prevents infinite loops when the agent can’t pass
  • goal_gate makes conformance a hard requirement for workflow success