Docs · Insights

Loop Economics

An autonomous agent loop re-sends its full context every turn, so input tokens drive the bill and an uncapped loop has no spend ceiling. That is fine when your tokens are subsidized. For everyone else it is real money. The Loop Economics scorecard reads five well-known cheaper-loop plays back to you — one row per play — with the findings that tripped it this window and the dollars behind it. It runs over telemetry your coding agent already produces; it adds no new detection and it does not run your loop.

The narrative companion is the blog post The loop you can actually afford. This page is the reference: what each play is, the rule that backs it, and how to read the two dollar figures.

The five plays

1. Write the spec before the loop

A loop pointed at a vague goal re-derives the goal every turn, on the meter. RepoOps flags this as the cost.spec-gapfinding: many sessions pump in fresh input but very little of the tool mix is actual edits — the “guess-tax” of an under-specified opening prompt. The fix: write the spec and the definition-of-done up front so the loop executes a known target instead of discovering one.

2. Plan cheap, execute expensive

Most of a loop’s steps do not need your top tier. The cost.downgrade-tier findings flag a surface pinned to a heavy model whose output is small enough that the next tier down is very likely fine. The LLM routing control tab opens the PR that makes the change.

3. Turn on caching

If your loop re-sends a stable prefix every turn, prompt caching makes that prefix nearly free after the first read. RepoOps flags the prompt- and surface-caching wins from your own cache-read numbers (cost.enable-prompt-caching, cc.context-health.cache-read-low). For a context-re-sending loop this is the single highest-leverage switch to flip.

4. Engineer the context: delegate reads, centralize writes

One growing context doing its own reading is the Cognition / Devin anti-pattern. cc.undelegated-readsnames the cause behind the symptoms you could already see — context bloat, a read-dominant tool mix, a low output-to-input ratio. The fix: delegate the reading to sub-agents that return conclusions, and keep one writer with a lean context.

5. Cap the run

An uncapped loop has no spend ceiling. cc.runaway-loopcatches the session that “finishes at turn 8, double-checks at turn 12, and is still going at turn 40” — a long run whose output-and-edit yield has collapsed — and estimates the dollars that spinning tail cost. The fix: set a maxSteps and a dollar ceiling so a stuck loop stops instead of spinning.

How to read the dollars

The scorecard is honest about money by construction. It never shows a fabricated saving. Each play can carry up to two figures:

A play whose waste cannot be cleanly priced reads unknown rather than a fabricated $0, and the headline totals sum only the priced plays. When several plays fire on the same root cause, the scorecard marks one of them start here— the single most actionable lead — so you act on one thing, not three alarms.

Where it lives

Open the Loop Economics tab (the Score category) in the dashboard, or hit GET /api/loop-economics?repo=<id>. It is presentation over the findings RepoOps already produces — point it at the agent you already run and it names the waste, play by play, with a fix on each one.