How to Test an OpenCode Patch Before You Merge

Check an OpenCode ledger fix in a clean copy. Catch a patch that returns the right total but silently changes the caller’s data.

Four original pieces stay in the test fixture while an orange tab marks the output check.

Before you merge a patch from OpenCode, run your usual tests and check what must stay unchanged. In our payment-ledger fixture, a deliberately faulty patch passed all six public tests and returned 585 correct totals, but preserved its input in only one case. A separate check for input mutation caught the defect. You can reproduce the check with the starter repository and reviewer script below.

1. Give OpenCode one small repair

Download the ledger repair fixture and reviewer (ZIP). It includes Python source, public tests and starter/PROMPT.txt. Run the baseline from the extracted kit root:

cd starter
python3 -m unittest -v

The starter is deliberately broken. Configure a working OpenCode provider and model, then launch OpenCode in the starter directory and paste the contents of PROMPT.txt. Keep the reviewer folder out of the files you send to the agent. Use a disposable checkout and inspect generated code before running it.

The brief is narrow. Count the first settled row for each transaction ID in integer cents. A pending row cannot reserve an ID, two different IDs can have the same amount, and the function must leave the original list and its rows intact. For example, pending A for 500, settled A for 500, duplicate settled A for 700 and settled B for 500 must give a total of 1,000. Review the changes before proceeding. Only ledger.py should change.

2. Run public tests and a separate input check

From the extracted kit root:

(cd starter && python3 -m unittest -v)
python3 reviewer/verify_patch.py starter/ledger.py

Require six passing public tests, 585/585 correct totals and 585/585 preserved inputs. The reviewer checks the total and the original records separately. If the totals pass but inputs fail, inspect the patch for operations that remove items, sort the list in place or edit a row. For your own repo, add an explicit regression test that compares the input with a copy after the call and verifies that another invocation with the same input gives the same result.

A deliberately faulty patch passed all six public tests and returned 585 correct totals, but preserved the input in only one case.

The input-consuming negative control is a local fixture. See the consumes_input row in the Ofox fixture results (CSV).

3. Verify an actual OpenCode response

On December 1, 2026, we sent this task with the starter code and public tests to DeepSeek V4.1 Flash 1017 through Ofox using OpenCode 2.2.5. We requested a replacement file in the response. The editor applied the replacement to a clean copy. The patched file passed all six public tests and both 585-case checks. The client took 42.53 seconds including startup. That one successful response matched an Ofox charge of $0.00116490. That amount covers one response. Earlier troubleshooting attempts and editor time are separate.

Download the replacement file, exact prompt, checks and matched charge (ZIP). Unzip it and run python3 -m unittest -v from the example folder. Then pass its ledger.py to the same independent verifier from step 2. The included test log shows what to expect.

If the tool cannot edit a file, check the permissions and working directory before trying again. You can also request a patch or replacement in the response, apply it yourself after review and run the same verifier. If a request fails before any patch arrives, check the API model ID and access. Record unsuccessful attempts separately and use Ofox usage tracking to reconcile them if you need a task total.