OpenCode Timeout: What Was Billed Before You Retry?

Check whether an OpenCode timeout left a usable patch, match completed calls to API charges, and retry one bounded task using a verified example.

Ink illustration of a half-closed zipper with an orange pull.

An OpenCode timeout can stop the coding session after several model calls have already completed. Before you rerun the task, check what changed in the repository and match completed calls to your provider’s usage records. Keep any call without a clear billing match open until you have evidence of what happened.

On December 1, 2026, our test runner stopped an OpenCode 2.2.5 session after 90.216 seconds. There was no file change at exit. We matched four completed model steps to US$0.00219226 on Ofox. A fifth step had started, and we could establish neither its server outcome nor its charge. This was a session deadline in our test runner. We did not observe an HTTP 504 for the last step.

Find the last step that actually finished

Keep the client version, provider/model, start and stop times with timezone, and the error or exit status. Inspect the output from your runner and the last OpenCode event. A process deadline, an HTTP error response and a stream that disconnects after some output are different observations. Record which one you saw. Check repository state before restarting, including untracked files. A tool invocation in the log alone does not prove a durable write.

If you already have a newline-delimited event log in the same format as our OpenCode 2.2.5 run, this filter keeps step boundaries and usage fields. Run it locally because a full event log can contain prompts or source code. Use the OpenCode CLI documentation or your installed version’s help for the logging options available to you.

jq -c '
  select(.type == "step_start" or .type == "step_finish") |
  {event: .type, timestamp, reason: .part.reason, tokens: .part.tokens}
' open-code-events.jsonl

In our saved log, the filter finds five step starts and four step finishes. An unmatched start marks where the local trace ends. Keep that step pending until you can match a provider record.

If the client received an explicit 429, check the error and any retry delay before sending another request. A 404 for an unavailable model calls for checking the model ID and route. For a local deadline with no final response, start with the provider’s Activity records and any existing tool effects. Ofox retry guidance · 429 troubleshooting · Model fallback 404

What the timed-out run actually cost

We used z-ai/glm-5.3-flash through Ofox in a disposable copy of an order-ledger fixture. The task was to count only the first settled receipt for each transaction ID. We matched completed client events to Ofox Activity rows using the model, attempt window, uncached input, cache reads and completion tokens. In this log, the completion count matched visible output plus reasoning tokens. The charges below come from the matched ledger, with times in UTC+8.

StepActivity timeInput / cache read / completion tokensMatched USD
115:07:211,990 / 0 / 1220.00035950
215:07:312,156 / 0 / 1230.00038490
315:07:37190 / 2,112 / 1,6970.00094036
415:08:201,782 / 2,240 / 3460.00050750
5No uniquely matched rowStart event onlyUnknown

The third completed step shows how the match works. OpenCode logged 416 visible output tokens and 1,281 reasoning tokens. Together they match the 1,697 completion tokens on the Activity row at 15:07:37. That same row lists 190 uncached input tokens, 2,112 cache-read tokens and a US$0.00094036 charge.

The four amounts sum to US$0.00219226. Our runner found no changed file at exit even though earlier events reported tool calls. A missing row for step 5 does not establish that the step was free. If traffic overlaps, prefer a shared request identifier when available. Use time, model and token matching only when the combination isolates a single row. See how to reconcile costs by key and model.

Retry the smallest task that can be accepted

  1. Inspect any existing diff and untracked files. Decide what work is already usable. For tools that modify an external system, verify the previous operation there before allowing another write.
  2. Freeze the original inputs and acceptance checks. Specify the missing output. Use a clean copy of the same fixture. If you want to inspect a patch first, include the relevant code and tests and ask for a complete replacement in the response.
  3. Check the returned result yourself. The separate run ended in 43.53 seconds and returned replacement source. An editor applied that source to a clean copy, then ran the acceptance checks. It passed 6 public tests, 585/585 integer total checks and 585/585 input preservation checks. A model’s statement that tests are expected to pass is a separate piece of evidence from a test run. Patch acceptance procedure
  4. Keep separate charges for separate attempts. The later response matched US$0.00125755. The two run windows therefore have US$0.00344981 in matched charges, with the last started step from the first run still unresolved. The later run returned source for an editor to apply. These records do not isolate the effect of any timeout setting.

For recurring jobs, store the accepted task count alongside the billing rows for completed and interrupted attempts. The monthly agent API cost tutorial shows how to turn that record into a forecast.