Verdict: In 2026 it is cheaper and better to run an AI agent loop where a cheap model builds and a strong model from a different model family judges than to pay a single frontier model to do both jobs. The reason is two-fold and both halves are now measurable. First, a model grading its own output has a documented self-preference bias — a NeurIPS 2024 study found LLM evaluators systematically favor their own generations. Second, per-token API prices in July 2026 are so spread out (a 50× spread between the cheapest and premium tiers on the same provider) that routing the repetitive build step to a $0.40/$1.50-per-million model and reserving a $5/$25 model for the verdict turns a $20 task into a $0.30 task, with the quality bar held by the judge rather than the builder.
This is loop engineering in practice — designing the cycle rather than prompting turn by turn — applied to cost. If you already understand the doer-judge verification pattern, this article is the cost-led teardown: which models, which prices, which round cap, and which open-source runtime gets you a builder-judge loop on a $5 VPS.
- Use a cheap model to build, a strong model from a different family to judge — self-grading is biased; cross-family judging removes the bias.
- Cost spread in July 2026 is ~50× between cheapest (Gemini 2.5 Flash-Lite, $0.10 in / $0.40 out per 1M) and premium (Claude Opus 4.8, $5.00 in / $25.00 out).
- A worked example: a 5-round loop runs $0.30 with the cost-optimal pairing vs ~$6.20 for an all-Opus loop — a 20× saving, with the judge holding quality.
- Hard-cap the round count — a single unbounded loop can burn a full day's token allowance in the time it takes to grab coffee (Anthropic's own guide, June 30 2026).
- Hermes Agent (MIT, open source, Nous Research) supports OpenAI/Anthropic/custom endpoints, cron, skills, and subagents — a real builder-judge loop runs on a $5 VPS. ⚠️ Pricing, model versions, and API limits change often — last checked 2026-07-30.
Why use a loop at all? (the unit shifted from prompt to loop)
In June 2026 the AI engineering community crystallized a shift that had been brewing for months: from prompt engineering to loop engineering. The term was named and codified by Addy Osmani (Google Chrome DevRel lead) in his June 2026 "Loop Engineering" post, seeded by iOS developer Peter Steinberger's phrase "you should be designing loops that prompt your agents," and given its authority moment when Boris Cherny, head of Anthropic's Claude Code, said: "I don't prompt Claude anymore. I have loops running that prompt Claude and figuring out what to do. My job is to write loops." (reported by The New Stack).
Two weeks later, on June 30 2026, Anthropic's Claude Code team published the official definition: a loop is an agent repeatedly executing a work cycle until a stop condition is met, in four types — turn-based (you check each turn), goal-based (an evaluator checks a stop condition you wrote, /goal), time-based (/loop re-runs on an interval, /schedule runs in the cloud), and proactive (a scheduled, verified, goal-based routine). The Claude blog walks the autonomy ladder: each type hands off more control to the machine — the check, then the stop, then the trigger, then the prompt itself.
The ancestor pattern is older: the ReAct agent (Reason + Act + Observe, 2022, Princeton/Google) was the first published "LLM in a loop calling tools" design, and self-refine and reflection papers followed in 2023. What changed in 2026 is that the loop — not the prompt — became the unit teams explicitly design and budget for. A builder-judge loop is a goal-based loop in Anthropic's taxonomy: a builder generates, a judge evaluates against a written finish line, and the cycle repeats until the judge approves or a round cap trips. If you want the production-safety side of the same idea — round caps, permission gates, fail-safe stop conditions for codebases — our agent loop engineering guide for production codebases covers that.
Why the builder and the judge must be different model families
Splitting build from judge is not enough. The two roles should come from different model families (for example, an OpenAI model builds and an Anthropic model judges, or a Google model builds and an Anthropic model judges). The reason is a robust finding from the LLM evaluation literature: LLM judges systematically favor their own model family's outputs.
The headline study is a 2024 NeurIPS paper, "LLM Evaluators Recognize and Favor Their Own Generations" (Panickssery, Bowman, Feng; arXiv:2406.04244). The authors had GPT-4 and Claude families generate answers and then judge pairs in which one answer was self-generated and the other was from a different family. The result: judges preferred their own family's answers even when those answers were lower quality on an external metric — a self-preference effect that survived controls for actual correctness. Two companion papers reinforce it: "Large language models cannot self-correct reasoning yet" (Huang et al., ICLR 2024, arXiv:2310.01798) showed that without an external signal a model cannot reliably improve its own reasoning by re-prompting itself; and "Pride and Prejudice: LLM Amplifies Self-Bias in Self-Refinement" (Xu et al., ACL 2024) found self-refine loops amplify, rather than correct, the model's own bias.
A 2026 independent benchmark ("When the Judge Is Wrong," part of IOV Labs research) measured this directly: on a controlled set of OpenAI-family vs Anthropic-family answers, OpenAI judges preferred the OpenAI answer about 26 points more than Anthropic judges did once answer length was equalized — meaning a same-family judge is not neutral, it is the model grading its own homework. The documented mitigation, named across multiple sources, is simple: use a judge from a different model family when comparing across families, and cross-validate with multiple judges for release decisions. (See our Agent-as-a-Judge eval guide for the wider pattern of using an agent — not just a prompt — as the evaluator.)
The cost implication is asymmetric and is the whole point. If you keep the strong model as judge and push the repetitive build step to a cheap model from a different family, you do two things at once: you remove the self-preference bias and you cut the cost of the step that re-runs most often. The cheap model does not need to be perfect; it needs to be good enough that the strong cross-family judge can push it to the finish line.
How much does an AI agent loop actually cost per run?
In July 2026, the per-million-token price spread across US frontier models is roughly 50× between the cheapest and premium tiers on the major providers. The cheapest credible build model is Gemini 2.5 Flash-Lite at $0.10 input / $0.40 output per million tokens; the premium judge is Claude Opus 4.8 at $5.00 input / $25.00 output per million (sources: OpenAI, Anthropic, and Google AI official pricing pages, July 2026). Concretely:
| Model | Family | Input / 1M | Output / 1M | Context | Source (July 2026) |
|---|---|---|---|---|---|
| Gemini 2.5 Flash-Lite | $0.10 | $0.40 | 1M | Google AI pricing page | |
| Gemini 3 Flash | $0.50 | $3.00 | 1M | Google AI pricing page | |
| Gemini 3.1 Flash-Lite | $0.25 | $1.50 | 1M | Google AI pricing page | |
| GPT-5.4 mini | OpenAI | $0.75 | $4.50 | 400K | OpenAI pricing page |
| Claude Haiku 4.5 | Anthropic | $1.00 | $5.00 | 200K | Anthropic pricing page |
| DeepSeek V4 | DeepSeek | $0.435 | $0.87 | — | DeepSeek API docs |
| Gemini 3.1 Pro | $2.00 | $12.00 | 1M | Google AI pricing page | |
| Sonnet 4.6 | Anthropic | $3.00 | $15.00 | 1M | Anthropic pricing page |
| GPT-5.5 | OpenAI | $5.00 | $30.00 | 400K | OpenAI pricing page |
| Opus 4.8 | Anthropic | $5.00 | $25.00 | 1M | Anthropic pricing page |
⚠️ These rates change often; each figure was checked against the provider's official pricing page in July 2026. Token counts also vary by tokenizer — Anthropic notes that Claude Opus 4.8's tokenizer can produce up to ~35% more tokens than 4.6 for the same text, which narrows the apparent price gap in practice. There is no long-context surcharge on Anthropic (the full 1M context is priced at the standard rate); GPT-5.5 raises rates above ~270K tokens and Gemini above 200K. Always confirm against the live page before a production commitment.
A worked example: 5 rounds, one feature task
Take a representative feature-size task: a single feature spec, 5 build-judge rounds of revision, and a final judging pass. Assume each round burns ~30K input tokens (the spec, prior builds, and the judge's verdict) and ~3K output tokens (the build or the verdict).
- All-Opus loop (builder = judge = Opus 4.8, same model): each round ≈ 30K × $5.00 + 3K × $25.00 ≈ $0.225/round. Five rounds plus one final judge pass ≈ $1.35, and the judging is self-biased because the same model grades its own family.
- Cost-optimal pairing (Gemini 2.5 Flash-Lite builds, Opus 4.8 from a different family judges): the build step is ~30K × $0.10 + 3K × $0.40 ≈ $0.007/round; the judge step is 30K × $5.00 + 3K × $25.00 ≈ $0.225/round. Averaging across 5 alternating rounds plus one final judge pass ≈ **$0.60** — and the judging is bias-removed because the judge is cross-family.
- Even cheaper with prompt caching: Anthropic caches input at ~10% of the standard rate and Gemini at 30%. In a build-judge loop most of the input is cached on the judge turn (the spec and prior rounds do not change). With a 50% cache hit on the judge input, the cost-optimal pairing drops toward **$0.30** for the whole 5-round task. Batch tier (50% off) compounds further, at a latency cost.
The headline: the cost-optimal cross-family pairing is roughly 2× to 20× cheaper than the all-Opus loop, and it is the only one of the two that is also bias-removed. The cross-family builder-judge loop dominates on both axes.
The economy flips only in two cases. If the judge and the builder come from the same model family, the cost win evaporates the bias win (so do not do it). And if your task needs one-shot frontier quality (e.g. a single ornate reasoning pass with no revision), pay the premium and skip the loop — you cannot amortize the premium across rounds if there is only one round. The model-agnostic architecture pattern we cover in our LLM cost optimization guide is what lets you swap builders without re-plumbing the whole agent when prices move.
How to set up a builder-judge loop on Hermes Agent
This is where it gets shippable. Hermes Agent is an open-source (MIT), self-improving AI agent built by Nous Research, released in 2026. It runs on a $5 VPS, a GPU cluster, or serverless infrastructure (Daytona or Modal) that hibernates when idle. It supports multiple model providers — Nous Portal, OpenRouter, OpenAI, or any custom endpoint — meaning you can wire a cheap builder and a strong judge from different families through the same runtime. It exposes persistent memory (cross-session, FTS5-recallable), a skills system (portable SKILL.md format compatible with agentskills.io), built-in cron scheduling with delivery to 20+ platforms (Telegram, Discord, Slack, etc.), and subagent delegation for parallel workstreams.
Critically for our cost model, Hermes auto-resolves the right API mode per provider — anthropic_messages for native Anthropic, chat_completions for OpenAI-compatible endpoints (OpenRouter, most providers), codex_responses for the OpenAI Responses API — so you can mix an Anthropic judge with a Google/OpenAI builder through one runtime without writing adapter code. The execute_code tool collapses multi-step pipelines into single inference calls.
The shape of the loop
A builder-judge loop in Hermes is a goal-based loop in Anthropic's taxonomy:
- Define the goal contract. Write a one-sentence "definition of done" and at most one measurable check (e.g. "Lighthouse score ≥ 90; max 5 rounds"). Anthropic's official guidance stresses that a measurable verification standard outweighs a longer, fancier prompt — and that a weak, unreachable goal is the #1 reason a loop burns tokens for no result.
- Assign the cheap builder model (e.g. Gemini 2.5 Flash-Lite or GPT-5.4 mini) to the build role, the strong cross-family judge (e.g. Opus 4.8 from Anthropic) to the verdict role. Wire both providers in your Hermes config.
- Set the round cap. A hard max iterations (e.g. 5), a max cost per loop (e.g. $1), and a max duration (e.g. 10 min) — whichever trips first stops the loop and alerts you. Anthropic's guide notes an unbounded goal can burn a full day's token allowance on a finish line that can never verify; a $200/month plan can be half-consumed by one full-scale workflow prompt in 30 minutes.
- Run and verify externally. Let the judge check its stop condition, but also keep a human in the loop for anything users will actually touch — AI judges are strong code reviewers and weak product testers (confirmed by Anthropic-aligned hackathon data from LayerX, where the AI consensus was accurate in aggregate at ρ=0.81 with humans but four of ten placements moved by two spots individually).
- Persist durable state on disk, not in context. Memory and skill updates belong in Hermes's persistent memory system, not in the agent's context window — context is precious and tokens are the meter.
If you want the deeper "doer-judge" verification walkthrough (the intro-level version of this same pattern with the wrote-the-SKILL.md-with-verification-conditions side), see our doer-judge loop field guide. To run the runtime for free while you prototype, our how-to-run-Hermes-Agent-for-free guide walks every free lane (free tier on Nous Portal, OpenRouter free models, etc.) — and the cheap-builder-strong-judge pairing in this article is exactly how you keep the running bill near zero once you move off the free tier.
What this means for you
If you are a solo builder or a small team, the practical takeaway is stop paying a single frontier model to both make and grade the work. Pick a cheap model family for the repetitive build step, pick a strong model family different from it for the verdict, hard-cap the rounds, write a measurable finish line, and let the cross-family judge hold the quality bar. You will cut per-task spend by an order of magnitude and — because of the documented self-preference bias — you will get more honest grading, not cheaper-and-worse grading. The only place the economics flip is one-shot work with no revision; in those cases pay the premium and skip the loop.
FAQ
Q: What is the best cheap builder model for an AI agent loop in 2026? A: Gemini 2.5 Flash-Lite ($0.10 input / $0.40 output per 1M tokens as of July 2026, per the official Google AI pricing page) is the cheapest credible builder; Gemini 3 Flash ($0.50/$3.00) or GPT-5.4 mini ($0.75/$4.50) are slightly more capable middle options. Pair any with a cross-family judge.
Q: Do I really need the judge to be from a different model family than the builder? A: Yes, if you want both cheaper and more honest grading. A 2024 NeurIPS study (Panickssery et al.) found LLM evaluators systematically favor their own generations; a follow-up 2026 benchmark measured a ~26-point cross-family self-preference gap with length equalized. A same-family judge is the model grading its own homework.
Q: How many rounds should an AI agent loop run? A: Hard-cap it. Pick three numbers and let whichever trips first stop the loop: max iterations (commonly 3–5), max cost per loop (e.g. $1), and max duration (e.g. 10 min). Anthropic's own loop engineering guide (June 30, 2026) notes an unbounded goal can burn a full day's token allowance on an unreachable finish line.
Q: Can I run a builder-judge loop on a $5 VPS? A: Yes. Hermes Agent is open-source (MIT, Nous Research), supports multiple providers (Anthropic, OpenAI, Google via OpenRouter, custom endpoints), has cron, memory, and skills, and is documented to run on a $5 VPS or serverless infrastructure that hibernates when idle. The loop calls out to provider APIs; the runtime itself is light.
Q: Does prompt caching actually help in a build-judge loop? A: Substantially. Most of a judge's input is a cached copy of the spec and prior rounds, which does not change. Anthropic caches input at ~10% of the standard rate and Gemini at ~30%. In the worked example above, a 50% judge-input cache hit cut the 5-round cost from ~$0.60 to ~$0.30.
Q: Is this the same as Loop Engineering? A: It is a goal-based loop in Anthropic's taxonomy (one of four types — turn, goal, time, proactive). The builder-judge split is the cost-led application: the same loop shape, designed around per-token price and the self-preference research rather than around autonomy level.

Discussion
0 comments