14  When the Loop Runs Itself (Advanced and Optional)

A useful test needs to check the thing you actually care about.

This optional chapter extends the conversation method to repeated, tool-using workflows. You can skip it and continue to Chapter 15 without missing the book’s core practice.

A loop takes a goal, proposes an action, observes a result, and decides whether to try again or stop. Software can perform those repetitions quickly. What matters is how the goal, permissions, checks, and stopping conditions are specified.

14.1 Separate the loop from the authority

A workflow that drafts a reply and a workflow that sends it are different systems, even if their text is identical. A loop may be allowed to propose a change while a separate component decides whether the change is permitted.

Name every action available to the system. Reading a file can disclose information; writing one can damage a record; sending a message affects another person. “It only has tools” is not a small claim. Each tool brings an access boundary and a possible consequence.

Also distinguish a fixed workflow from an agent that chooses its own next steps. Either may suit a task. More autonomy is not automatically more useful. Anthropic’s practitioner account recommends starting with simpler patterns and adding complexity when justified by the work. Building effective agents

14.2 The test must sit outside the proposed answer

Suppose a loop edits a small program. An independently maintained test suite can check outputs for known inputs. That provides stronger evidence than asking the editing model whether its code is correct.

But a test suite is finite. Passing it does not establish every property of the program. A loop can exploit an incomplete metric, satisfy the examples while failing elsewhere, or alter the environment in a way the evaluator did not anticipate. Protecting the test file is helpful; it is not a universal safety proof.

For a writing task, a word-count limit is easy to check. Preservation of a contractual qualification is harder. If the loop learns to shorten by removing every caveat, it can improve its score while making the document less useful. You have optimised the measure, not necessarily the purpose.

14.3 A bounded loop specification

Before enabling an automated loop, record:

Element Question to answer
Goal What outcome should improve, and for whom?
Inputs Which sources and versions may be used?
Permissions What may be read or changed, and what is prohibited?
Evaluation Which independent checks must pass, and what do they miss?
Budget Maximum attempts, time, cost, or resource use
Review gate What requires a human decision before taking effect?
Stop and recovery What halts the loop, who is notified, and how is the previous state restored?

A “keep going until done” instruction without these boundaries is not a plan. The system may be unable to reach the goal, unable to recognise completion, or rewarded for the wrong thing.

Use a disposable environment and synthetic inputs for practice. Do not test a stopping rule by allowing an agent to act on real customer accounts or messages.

14.4 Worked example: a shorter notice

Use this invented source notice:

Group 2 starts at 14:45. Arrive for your allocated session. The room holds 12 people including facilitators. The organiser must confirm arrival arrangements before invitations are sent.

The loop’s task is to shorten the notice while retaining the start time, capacity definition, and pending confirmation. A word-count check is one evaluator; a checklist of preserved facts is another.

A proposed revision says:

Arrive at 14:45. The room holds 12 participants. Invitations are ready to send.

It is shorter. It also changes total occupancy into participant capacity and converts an outstanding confirmation into approval. A loop using only length would prefer it. A source-preservation check rejects it.

A better revision says:

Group 2: 14:45. Room limit: 12 including facilitators. Send invitations only after the organiser confirms arrival arrangements.

A reviewer can trace each clause to the source. The approval gate still belongs outside the loop. Neither a good draft nor the model’s statement “all checks passed” authorises sending.

14.5 Search can produce useful novelty

Repeated proposal and evaluation can discover combinations or solutions that were not explicitly supplied. There is no need to dismiss every such result as merely the appearance of creativity.

Equally, a novel-looking result does not establish validity. Ask what was new, how it was evaluated, whether the comparison was fair, and what assumptions the evaluation left untouched. Claims about what all future models could never discover are unnecessary to this decision.

The practical boundary is the quality of the evidence and the consequences of action. If the evaluator does not capture a requirement, repeated optimisation does not make that requirement disappear.

14.6 When the loop loses the thread

A long-running process needs records of completed work, current assumptions, failed attempts, and the remaining objective. That record may be stored outside a model’s context. A summary can help, but it can also omit a constraint or preserve an error.

Check the handover at each restart. If a source changes, a tool fails, permissions expire, or the budget is reached, stop or escalate according to the specification. Do not let an unavailable check become an implicit pass.

A model-generated explanation of its behaviour can be useful evidence about what it says it did. Compare it with actual tool logs and outputs before relying on it. The prose is not an audit trail by itself.

14.7 Independent practice: inspect an optimiser

Time: 20 minutes. No model required. Use the notice above and imagine three checks: length under 30 words, correct time, and no sending without approval.

  1. Mark what each check would catch in the bad revision.
  2. Identify the missing capacity check.
  3. Add a stop condition for a missing source or uncertain requirement.
  4. Name which actions must remain unavailable during testing.
  5. Write a candidate revision and check it against the original.

Artefact: a loop specification and checked notice. Success: preserve the capacity definition and pending approval, explain why length alone fails, and prohibit sending during the experiment. An automated extension may implement the checks, but the independent reasoning is the core task.

14.8 Where the human stands

Some bounded tasks can run with limited review; others need approval at a consequential step; some should not be automated in the available environment. Decide from the use, the evidence, and the failure cost.

That role may change as tools change. The book does not promise permanent immunity from automation. It asks you to remain able to specify the task, inspect the evidence, notice a failed assumption, and account for the decision. A loop can accelerate parts of the work without making those questions unnecessary.