Patterns
Goal Loops and Interval Composition
Autonomous Agent Systems Β· Loop Orchestration Β· Production Workflows

Goal Loops and Interval Composition

Verifiable autonomy, separate-evaluator architectures, and composing schedules with finish lines.

GOAL LOOPS AND INTERVAL COMPOSITION

3. The Goal Loop: Verifiable Autonomy

3.1 The separate-evaluator architecture

The mechanism that makes a goal loop trustworthy β€” rather than merely convenient β€” is that the model doing the work and the model deciding whether the work is done are different instances, often different model classes entirely (a smaller, faster model such as Haiku typically serves as the evaluator). After each turn, the transcript and the stated condition are passed to this evaluator, which answers one question: is the condition met? A “no” returns a reason, which becomes the instruction for the next turn; a “yes” clears the loop.

This separation exists for the same reason peer review exists in any engineering organization: a single actor grading its own work is subject to confirmation bias and will converge on “looks done” rather than “is done.” Splitting execution from judgment is the architectural primitive that everything else in this builds on β€” it recurs at the orchestration level (Section 5), at the self-improvement level (Section 8), and in the governance controls an enterprise reviewer will actually ask about (Section 9).

3.2 The one constraint that governs condition design

The evaluator can only read the transcript β€” it cannot execute commands, inspect files, or run tests itself. This single constraint dictates the entire craft of writing a usable condition: the condition must describe an observable end state, and the work itself must print its own proof into the conversation.

A condition like “clean up this file” or “improve the test coverage” gives the evaluator nothing concrete to check, so the loop either spins indefinitely or the evaluator hallucinates completion. A condition like “npm test exits 0 with no failures in test/auth, and npm run lint is clean” succeeds because the proof β€” the command’s output β€” lands directly in the transcript.

A well-formed condition has four components, and treating this as a checklist materially improves reliability in practice:

ComponentPurposeExample
End stateThe measurable result being targeted“all tests in test/auth pass”
Stated checkThe command that produces the proof“run pytest test/auth -q and show output”
ConstraintsWhat must not change in pursuit of the goal“do not touch the schema or migrations”
CapThe circuit-breaker“stop after 20 turns and summarize”

Goal-conditioned execution is not limited to “make the tests pass.” Any target for which a runnable check exists is a candidate: type-checking after a refactor, coverage thresholds on a specific module, latency budgets surfaced by a load-test report, reproduction-then-fix of a reported bug, removal of every reference to a deprecated API, or invariants over a structured data file. The unifying requirement is always the same β€” if you cannot name the command whose output flips from “no” to “yes,” the goal is not yet ready to run unattended.

A recurring failure mode worth naming explicitly: the cheapest way for a model to satisfy a check is often to weaken the check rather than do the work β€” deleting a failing test, stubbing a call site, or narrowing scope quietly. Conditions should include explicit negative constraints (“no call site is deleted or stubbed to achieve this”) specifically to close that path.


4. Interval Loops and Composition

Where a goal loop has a finish line, an interval loop has a clock. It re-runs a body of work on a schedule or in response to a trigger, with no notion of “done” β€” it is designed for standing, continuous concerns: watching a deployment, polling for new work, or running a recurring maintenance chore.

The architecturally important point is that cadence and completion are independent concerns that compose. A production pattern is a scheduled trigger whose body is itself goal-bounded: the schedule decides when a cycle starts, and the goal decides when that cycle is finished. Conflating the two produces two predictable and expensive failures: a continuously re-firing interval loop wrapped around already-finished work burns budget forever on the clock, while a goal condition applied to genuinely open-ended monitoring work never terminates because no state exists that would satisfy it.

Interactive Tools

Practical tools to help you think systematically, build better AI agents, and master prompt engineering.

Future References

Explore these resources for deeper learning on AI agent development, spec-driven development, and prompt engineering tools.

Spec-Driven Development

Comprehensive guide on Spec-Driven Development practices and methodologies.

Awesome Copilot

Curated list of GitHub Copilot resources, extensions, and best practices.

Promptfoo

Tool for testing, evaluating, and improving LLM prompts and applications.

Prompts.chat

Collection of prompt engineering resources and templates.

Agent Skills

Agent skills resources and documentation for building AI agent skills.

Awesome Skills

Curated list of awesome skill repositories and collections.

Agent Skills Topic

GitHub topic for discovering agent-related skills and repositories.

AI Agent Topic

Trendshift topic for discovering AI agents.

AI Skills Topic

Trendshift topic for discovering AI skills.

Agent Governance Toolkit

Agent governance toolkit.

Pattern Sources

Our patterns are curated from industry-leading sources with proper attribution and licensing compliance.

Refactoring.Guru

Classic GoF design patterns, code smells catalog, and refactoring techniques (https://refactoring.guru).

Enterprise Integration Patterns

65 messaging patterns for integrating enterprise applications by Gregor Hohpe and Bobby Woolf (CC BY 4.0).

Microservices.io

Comprehensive patterns for microservice architectures by Chris Richardson.

Agent Catalog Patterns

Patterns for agentic systems from agentpatternscatalog.org (CC BY 4.0).

OWASP Foundation

Security patterns from OWASP Top 10 for Web Applications, LLM Applications, and Agentic Applications (CC BY-SA 4.0).

Industry Research

ML/AI patterns from Microsoft, Google, Anthropic, and academic research.

AI Agent Patterns

Spec-driven development patterns from Claude, Gemini, OpenAI, and GitHub Copilot on github/spec-kit and OpenSpec.

Data Engineering Leaders

Data platform patterns from Martin Fowler (Data Mesh), Kimball Group (Dimensional Modeling), and cloud providers.

MLOps Best Practices

Data science patterns from MLflow, Great Expectations, and MLOps practitioners.

Streaming & Analytics

Real-time patterns from Confluent/Kafka, Apache projects, and serverless analytics platforms.

Academic Papers

Rigorous ML patterns from peer-reviewed research including data leakage prevention and active learning.

5-Day AI Agents Course

Intensive Vibe Coding Course With Google by Brenda Flynn et al. (2026) on Kaggle.

The Agent Loop

Foundational Agent Definition (Perceive + Act):
Russell, S. J., & Norvig, P. (1995). Artificial Intelligence: A Modern Approach. Prentice Hall. (Current edition: 4th Ed., Pearson, 2020)

Modern Iterative LLM Agent Loop:
Yao, S., Zhao, J., Yu, D., et al. (2022). ReAct: Synergizing Reasoning and Acting in Language Models. arXiv:2210.03629.

Historical Context:
Incorporating AIMA's perceive/act model, Classical robotics' Sense-Plan-Act loop (Brooks, 1986), and ReAct's Thought→Action→Observation cycle.