# Recursive loops: how agent work improves itself

> The general pattern by which any agent workflow improves from its own results: an independent check, feedback into the next attempt and a person's approval. Examples by workflow, the LightHouse features each step uses, and recursive engineering, the software delivery case.

A **recursive loop** is the way an agent workflow improves from its own results. Each attempt is judged by a check the agent does not control, and the result changes how the next attempt is made. The pattern applies to any agent workflow. Software delivery is one case, described below as [recursive engineering](#recursive-engineering).

## The pattern

1. **An agent produces work**: an answer, a draft, a reconciliation, a code change.
2. **An independent check judges it.** The agent never marks its own work. The check is something outside it: a test suite, a rubric scored by a separate reviewer, a reconciliation total, or a real outcome such as a ticket that stays closed.
3. **The result feeds the next attempt**, through the client’s own versioned material: team memory, run books, rules, prompts, templates and evaluation sets.
4. **A person approves before anything is acted on.** LightHouse™ enforces this with [approvals](/concepts/approvals/), and records each decision as [evidence](/concepts/evidence/).

No model is trained or fine-tuned on client data by a recursive loop. What changes is material the client owns and can read, compare and roll back.

## The limit

A loop is only as good as its check. A pass or fail result, such as a test run or a total that ties, is the strongest check. Where the outcome is a matter of judgement, such as the tone of a reply or the completeness of a policy mapping, a rubric scored by a second model can serve as the check only if people calibrate it regularly: a person scores a sample of the same work, and the rubric or the reviewer is corrected where the two disagree. An uncalibrated reviewer drifts, and the loop then improves the work towards the reviewer’s errors.

## Examples

| Workflow                          | What the agent produces                                            | The independent check                                                                               | What feeds back                                                                                                                     |
| --------------------------------- | ------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Software engineering              | Prompts for each delivery stage, code changes, draft pull requests | The repository’s tests and checks; review by a person who did not write the change                  | Outcome reasons into template revisions; regenerated test and security prompts. See [Recursive engineering](#recursive-engineering) |
| Support and service desk          | Triage and draft replies                                           | Whether the ticket is reopened; a calibrated rubric scored by a separate reviewer                   | Team memory and reply guidance                                                                                                      |
| Finance close and reconciliation  | Matched entries and reconciliations                                | Totals that tie to the ledger and the bank statement                                                | Matching rules and the list of known exceptions                                                                                     |
| Compliance and policy mapping     | Mappings of controls to policy clauses, with gaps noted            | A reviewer’s check of each mapping against the clause text, sampled and calibrated                  | Mapping rules and evaluation cases                                                                                                  |
| Knowledge base answers            | Cited answers from Octy™                                           | Ratings from the person who asked; citations checked against the passages retrieved; the golden set | Accepted evaluation cases, team memory and updated source pages                                                                     |
| Operations and incident run books | Diagnoses and proposed remediation steps                           | Whether the remediation resolved the incident                                                       | Updated run books and post-incident notes                                                                                           |
| Data and reporting                | Queries and reports                                                | Control totals from the source system; tests on the queries                                         | The query library and report definitions                                                                                            |

## In LightHouse

| Step      | Features                                                                                                                                                                                                                                                                                          |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Produce   | [Agents](/concepts/agents/) and their cards; [Octy](/octy/); the coding agent, a card with `executor: agent`                                                                                                                                                                                      |
| Check     | [Evaluations](/build/evaluations/), with golden sets and the release gate; Octy answer ratings and [feedback](/octy/channels/#api), where a down-rated answer becomes a candidate evaluation case that a reviewer accepts or rejects; a repository’s own tests                                    |
| Feed back | Octy team memory, notes a team keeps for Octy and screens on save; scheduled questions, which ask a standing question again on a cadence; [Confluence page drafts](/connect/confluence/#writing-with-approval), for updating run books and guidance pages; prompts, templates and evaluation sets |
| Approve   | [Approvals](/concepts/approvals/), with a named person for every output that has an effect; [evidence](/concepts/evidence/) for what each answer and decision rests on                                                                                                                            |

## Scoring and evidence

**Scoring is the loop’s independent check.** A change to an agent is scored against the version in use, on the same cases, before anyone decides on it. A change of an agent’s model is refused unless a replay of that model passed on the agent’s current prompt and configuration; a later change to the prompt or configuration makes the earlier result count for nothing. See [Replay evaluation](/router/evidence/#replay-evaluation).

**Evaluations are where the loop learns, under control.** Real failures become evaluation cases: a down-rated Octy answer is proposed as a candidate case, with its question, answer and cited sources kept in the deployment. A named reviewer accepts or rejects each proposal, and only accepted cases join the evaluation set, so the set never changes itself.

**Evidence links each change to what it rested on.** Each comparison is kept in the client’s deployment under a digest of its content and sent to LightHouse as an evaluation record carrying metrics only. The release record for the change carries the same digest, so a change in LightHouse leads back to the comparison and the approval behind it. A change that did not pass its gate goes ahead only by an override that a person approves in LightHouse against that comparison; a standing pre-approval cannot stand in for it. No prompt, answer or document leaves the client’s account.

| Loop step              | Mechanism                                                                                         |
| ---------------------- | ------------------------------------------------------------------------------------------------- |
| Independent check      | Scoring against the version in use on the same cases; replay on the agent’s current configuration |
| Learning from failures | Candidate cases from down-rated answers, accepted or rejected by a named reviewer                 |
| Approval               | The gate, or an override approved by a person in LightHouse                                       |
| Record                 | The comparison under its digest; evaluation and release records in LightHouse                     |

## Recursive engineering

**Recursive engineering** is the recursive loop applied to software delivery. It runs at three levels in the client’s deployment of the Atlantic Agentic Engine. Each level follows the same practice: a written specification before the build, a check that comes back pass or fail, and review by someone other than the author.

| Loop                                                        | What repeats                                                                         | Where it stops                                                                                                   |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------- |
| [Inside one prompt](#inside-one-prompt)                     | Draft, critique, redraft                                                             | The critique passes, or the round limit is reached; then a person signs off                                      |
| [Across the stages of a task](#across-the-stages-of-a-task) | Each stage’s signed output feeds the next stage; in the code stage, write, test, fix | A person signs off between stages; the coding agent stops when the tests and checks pass or its limits are spent |
| [Across tasks](#across-tasks)                               | Outcomes are recorded, templates revised, test and security prompts regenerated      | A revision takes effect only after evaluation and a person’s approval                                            |

### Inside one prompt

A delivery stage’s prompt (a story refinement, a design, a code change, a test plan) is the specification. The engine gathers the ticket, design pages, conventions and code passages from the client’s knowledge base within the requesting person’s access, citing each, and asks the person only for what the sources do not answer. It drafts the prompt from the stage’s versioned template, then critiques it: checks that need no model run first (required sections, citations that resolve, no credential-shaped strings, no instruction-like text from a source), then a model critique against the stage’s criteria, which can add problems but cannot remove the checks’ findings. The prompt is redrafted until the critique passes or the round limit is reached.

A person then signs the prompt off. It is signed with the deployment’s key and verified before every use, so an agent, or an IDE assistant through the engine’s MCP server, works from exactly the text a person reviewed. Sign-off is not offered as a tool, so an assistant cannot sign off on a person’s behalf.

### Across the stages of a task

A delivery pack defines the stages a task passes through, typically story refinement, design, code, tests, review and documentation. Each stage’s signed output is an input to the next, and a person signs off between stages.

In the code stage, the coding agent (`executor: agent`) takes only a signed, signed-off prompt. It works on a branch of its own in an allow-listed repository, never a protected branch, and writes code, runs the repository’s tests and checks, and fixes what failed until they pass or its limits on test runs, model turns and budget are reached. The tests are its check: the loop ends on a pass or fail result, and each run is recorded. A person approves the drafted pull request in LightHouse before it is opened, as a draft. No agent merges. Every model call goes through the client’s own [gateway](/concepts/gateway/).

### Across tasks

Every signed prompt records its outcome once: **accepted**, **reworked** or **rejected**, with reasons from a fixed list so that the same weakness is counted the same way each time. From those records:

- **Outcomes are reported** by stage, template version and repository.
- **Templates are revised.** Where a stage’s prompts are often reworked for the same reasons, a revision is drafted, evaluated against the current template on the stage’s evaluation cases, and takes effect only after a named person approves it in LightHouse. A revision that scored worse, or could not be evaluated, is approved only with an explicit acknowledgement.
- **Test and security prompts follow the code.** When a repository’s coverage falls or new security findings arrive, its test or security prompt is regenerated, and remains a draft until a person signs it off.
- **Agents are held to their evaluation sets** and released only if they pass the [release gate](/build/evaluations/#the-quality-bar-the-release-gate).
- **Retrieval is measured against what people ask.** Verdicts on Octy answers are recorded as retrieval feedback ([Octy channels](/octy/channels/#api)), and unanswered questions can be added to a golden set.

## What never happens

- **No model is trained or fine-tuned on client data** by any recursive loop. Training a model is a separate capability, off by default, which runs only in the client’s own environment when the client switches it on: see [Training datasets](/concepts/training-datasets/).
- **Nothing activates itself.** A revision is a proposal until a person approves it, and activation checks the approval’s signature over the proposal’s exact text. A trigger regenerates a prompt and leaves it unused until a person signs it off.
- **No agent merges.** The coding agent’s change reaches a repository only as a draft pull request, after a person’s approval, under the repository’s own review and merge rules.
- **No agent approves its own work**, and neither does a machine key. See [Approvals](/concepts/approvals/).

## Where data lives

Everything a loop reads and writes stays in the client’s deployment: the knowledge base, prompts and their signed records, outcomes and their reasons, team notes, proposals and their evaluations, repository clones and change sets. Review comments are read in the deployment for their reasons and are not kept.

Model calls go through the client’s own gateway to the models the client’s policy allows. LightHouse receives content-free records: counts, outcomes, reason categories and approval decisions, with repository names replaced by keyed references. No prompt text, code, review comment or finding text reaches LightHouse or Atlantic. See [The telemetry contract](/concepts/telemetry-contract/) and [Where everything lives](/data-sovereignty/where-everything-lives/).

## The controls

| Control                    | What it holds to                                                                                                                                         |
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| A person’s sign-off        | Every prompt, stage handover, revision and pull request is decided by a named person                                                                     |
| Signed prompts             | A prompt is signed when it is built; the signature and every sign-off are verified before each use                                                       |
| Sealed sources             | Text read from a source reaches the model fenced and marked as evidence to cite, and is screened for instruction-like content                            |
| Approval in LightHouse     | Revisions, pull requests and write cards are approved through LightHouse’s approvals, with the same rules as any agent output                            |
| Evaluation before approval | A template revision carries its comparison against the current template; an agent release passes the release gate                                        |
| Repository limits          | The coding agent works only in allow-listed repositories, on its own branch, never on protected branches, and cannot change the pipeline’s configuration |
| Test isolation             | The repository’s tests run without network access by default, with an environment built for the run and no engine credentials                            |
| Budget and turn limits     | Every loop has a cap; the gateway refuses a call that would cross the budget                                                                             |
| Evidence                   | Each outcome, proposal, decision, activation and regeneration is a signed record in the deployment, and its content-free summary reaches LightHouse      |

## Measurement in principle

- **Rework rate.** For each workflow and template version, the share of decided outputs that were reworked or rejected.
- **Reasons**, counted in a fixed vocabulary, so weaknesses can be compared over time.
- **Old against new.** A revision is scored on the same evaluation cases as the current version before anyone approves it.
- **Release gate.** An agent or model change is compared with the last release on the same golden set. See [Evaluations](/build/evaluations/).
- **Coding agent comparison.** Models are compared on synthetic repositories with failing tests; a case counts only when the change passes on a fresh clone and the agent left the tests untouched.

The figures that decide when a revision is due are configuration, set per deployment.

## Relation to published practice

The loops follow patterns that Anthropic, the developer of the Claude models, describes in its public guidance:

- **Inside one prompt** is the evaluator–optimizer workflow in Anthropic’s [Building effective agents](https://www.anthropic.com/engineering/building-effective-agents): one step drafts, another evaluates the draft against stated criteria, and the two repeat until the draft passes.
- **Across the stages of a task** follows Anthropic’s [best practices for Claude Code](https://code.claude.com/docs/en/best-practices): a written specification before the build, a check the agent can run that comes back pass or fail, and review by someone who did not write the code.
- **Across tasks** follows Anthropic’s [prompt engineering guidance](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/overview) and [Define success criteria and build evaluations](https://platform.claude.com/docs/en/test-and-evaluate/develop-tests): set success criteria and a way to test against them before changing a prompt, and change prompts on measured results.

Atlantic adds controls for regulated environments that the published guidance does not prescribe: a named person’s sign-off between stages, signatures that bind an agent to the prompt a person reviewed, approval before any change takes effect, and a signed record of each outcome, approval and revision.

This section describes the product’s design in relation to published guidance. It does not describe Anthropic’s internal practice, and it implies no endorsement by Anthropic.

## Under NDA

How to set up a loop (choosing the check, where the feedback is kept, the approval step) and how the recursive engineering loops are configured, with their defaults, outcome reasons, regeneration inputs and the coding agent’s limits, is in the client documentation, for clients and prospects under a non-disclosure agreement. See [Verify it yourself](/security/verify/#what-we-will-show-under-nda).

Source: https://docs.atlanticagenticlabs.com/build/recursive-loops/
