Before submitting#
Area#
apps/server
Steps to reproduce#
- Use OpenCode 2 with only an OpenCode Go key in auth, and an empty or zero Zen balance
- Pick a paid Zen model on a thread, e.g.
opencode/deepseek-v4.1-flash (not opencode-go/..., not a -free model)
- Send any message
You can see the same failure outside T3 with opencode run -m opencode/deepseek-v4.1-flash "Reply with exactly: OK", which prints Error: Upstream request failed: Insufficient account funds. opencode-go/deepseek-v4.1-flash answers fine.
Expected behavior#
The thread fails with a normal provider error that shows OpenCode's message ("Insufficient account funds"), so it's obvious you need to top up or switch models.
Actual behavior#
Every send fails in about 1s and the composer shows "Usage limit reached / Reset time unavailable; retry manually" with no actions. The real message is hidden. That points you at a usage window that doesn't exist, and since out of funds never resets, auto-resume/reset scheduling can't work anyway. I retried 4 runs in a row before figuring out it was billing.
The cause is in packages/provider-opencode/src/server/v2/adapter.ts: session.execution.failed maps every provider.quota / provider.rate-limit to class: "usage_limit". OpenCode types the billing stop as provider.quota too, so it gets the same treatment. The mapping came from #16366, which was right for real Go limit windows but catches billing failures as well.
Stored failure on the run:
class=usage_limit code=provider.quota resetAt=NULL
message="Upstream request failed: Insufficient account funds"
Suggested fix (I have it locally with tests, can PR if wanted):
- adapter: treat
provider.quota whose message is a billing failure (insufficient funds/balance/credits, billing) as provider_error; real limit windows stay usage_limit
- web
UsageLimitRecoveryBanner + mobile UsageLimitRecoveryCard: when there's no reset time, show the provider's lastError instead of the generic "Reset time unavailable; retry manually"
Impact#
Blocks work completely
Version or commit#
main @ fcb20e49aa
Environment#
Ubuntu 24.04, opencode v2.1.1, provider OpenCode 2, model opencode/deepseek-v4.1-flash (Zen)
Workaround#
Switch the thread to opencode-go/<model> or a -free model, or top up the Zen balance.
Note
Grok responding on behalf of Julius.
Thanks for the stored failure, it lines up with current main. The OpenCode 2 adapter classifies every
session.execution.failedwith typeprovider.quotaorprovider.rate-limitas a usage limit and everything else as a provider error (packages/provider-opencode/src/server/v2/adapter.ts:2185-2197). OpenCode reports running out of funds asprovider.quotatoo, so it's treated as a usage limit with no reset time. The usage limit banner then shows only "Reset time unavailable; retry manually", not OpenCode's own message (apps/web/src/components/chat/UsageLimitRecoveryBanner.tsx:30-33).An empty balance doesn't reset, so it should show as a normal provider error with OpenCode's message, the same way #19848 stopped a full Claude context window from showing as a usage limit.
Accepting this as a bug.