Loading articleโฆ
Loading 4weirdโฆ
Loading 4weirdโฆ
Loading articleโฆ
DocsHeal loops
Docs ยท desktop ยท opencode
Heal loops bugtest โ fix โ re-test until the suite is clean or a budget trips โ iteration count, token cap, or spend cap, whichever hits first. Coin quotes follow the house rule (100 coins = $1, 75/25 split); MCP-mediated payment is a queued future where only stubs exist today.
The loop
Export writes the BUGFIX-<game>-<stamp>.md/json report; Fix hands it to OpenCode so it edits code itself and shows the diff; Heal repeats test โ fix โ re-test until clean or the iteration budget is spent. Swarm agents reach the same loop via the opencode.export / opencode.heal tools.
opencode run -f file, the desktop Fix button, or the opencode.heal tool) so it edits code and shows the git diff.Budgets
Iteration caps alone cannot price a loop โ one round can burn far more tokens than the next. The heal budget tracks input/output tokens, prices them, and stops on max tokens or max spend (USD), with per-iteration ledger lines. Integer-token accounting, fail-open clamps, never exceeds budget.
maxTokens
Hard cap on input + output tokens across all rounds. Trips before max iterations in a heavy run.
maxSpendUSD
Hard cap on priced spend. A run with maxSpendUSD set tiny stops on spend, not on round count.
Per-iteration ledger
Every round logs its token usage so the stop reason is auditable after the verdict.
Coin quotes
Heal-loop cost estimates are read-only quotes in integer coins: 100 coins = $1.00, provider keeps 75% as on-site credits, platform keeps 25% for infrastructure. Quotes never write to any ledger โ settlement stays a later lane.
Example: a 400-coin ($4.00) job โ 300 coins provider credits, 100 coins platform. You only ever see the gross 400. All credits are on-site only (cloud compute, game credits, other on-site services); never cash-out, never withdrawable.
MCP pay
Driving bugtest + fix remotely (terminal exec, heal start/status, opencode fix tools over MCP) and paying for it in coins is the queued future: where only stubs exist today, this page describes intent, not a live payment path. Nothing here debits a wallet.
Worked example
Follow one stubbed suite through the loop: it fails twice on the same assertion, then passes. Every round logs tokens so the stop reason is auditable.
Stop reasons
The verdict names exactly one stop reason. Learn the four so a Heal result never surprises you.
| Stop reason | What it means | What to do next |
|---|---|---|
| Clean | Suite passed fully on a retest round. | Review the diff, keep the fix, ship the game. |
| Max rounds | Iteration cap hit while failures remain. | Shrink the repro, raise the cap deliberately, re-heal. |
| Max tokens | Cumulative input plus output tokens hit maxTokens. | Trim context in the report or raise maxTokens, then resume. |
| Max spend | Priced spend hit maxSpendUSD first. | Check the per-iteration ledger, price the next attempt with a coin quote, re-run funded. |
FAQ
Pricing, quoting, and payment futures in one place. Start on the setup page if the binary itself is missing.
How do I price a loop before starting it?
Take the last similar verdict, sum its ledger tokens, price them at your provider rate, then convert dollars to coins at 100 to 1. That quote is read-only: it predicts, it never debits.
Why did my loop stop on round 2 with failures left?
A token or spend budget tripped before the round cap. Open the verdict ledger: the stop reason names the exact cap and the round totals that crossed it.
Can Heal pay the provider in coins today?
No. MCP-mediated coin payment is queued future with stubs only. Quotes today are estimates; any future settlement needs its own guarded lane with auth and audit.
Where does Export fit in?
Export writes the BUGFIX report that round 1 consumes. Revisit Desktop OpenCode setup for the report format and the cli versus server choice.