fix(opencode): OpenCode Go quota stops show as usage limits#18315

merged5
main
GitHub fork: fix/opencode-usage-limit
opened29d agobyMMarker-bit
View on GitHubTwo-way sync enabledPR last imported 20d ago

OpenCode 2 reports quota and rate-limit stops with typed error codes, but the adapter classified both as generic provider errors. Map provider.quota and provider.rate-limit to usage_limit while preserving the native code and all other error handling.

No reset time is invented: OpenCode does not include one in these events. OpenCode 1 uses a different protocol and is unchanged. Original implementation by @Marker-bit in #18315; maintainer takeover preserves that history.

Validation: focused adapter suite 103 → 104 cases after replacing two duplicated tests with one three-case table. Removing the mapping fails the quota and rate-limit cases (102 pass); restoring it passes all 104. Provider-opencode and server typechecks plus targeted lint/format checks pass. Existing headless orchestration queue and usage-limit recovery checks pass 23 selected cases. Independent adversarial review: two parallel rounds; first round found only an unrelated comment, now removed, and both second-round reviewers found no issues.

The replay tests drive the real adapter against a deterministic OpenCode protocol fixture; the runtime checks exercise server recovery state. No interactive UI or native client proof is claimed. A real exhausted OpenCode Go account was unavailable. macOS, Windows, iOS, Android, and Electron desktop were not verified.

CI follow-up: all server shards, lint, build, typecheck and the full web suite now pass on the reviewed head. The first web run failed one untouched syntax-highlighting assertion in WorkflowOpeningBlock.browser.test.tsx:103 (1 / 8,048); the focused Chromium suite passed locally (3 / 3), and one failed-job retry passed: CI run. A duplicate fingerprint run was canceled; the other fingerprint run succeeded.

Maintainer work: Codex GPT-6 Astra (tests), GPT-6.1 Sol (implementation), Claude Opus 5.5 and GPT-6 Sol (adversarial review), through T3 Code delegation and Codex harness.

Checks

24 successful · 10 skipped
All checks passed
08740fb

Added 1 commit

  • fix(opencode): OpenCode Go quota stops show as usage limits8eb2f13
Synced from GitHub

Approvability

Verdict: Approved at 08740fb

Macroscope's review found this PR approvable — This is a narrowly scoped, well-tested correction to classify OpenCode quota and rate-limit failures as usage limits instead of generic provider errors. It has no product-default, schema, deployment, security, billing, or static-analysis changes.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Path: .coderabbit.config.ts
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d7542d3-e098-4334-b040-107dc8e81ed0
📥 Commits

Reviewing files that changed from the base of the PR and between 8eb2f1399d6cdf7b0c309544b3963b257ddc37f1 and 08740fb86940783005955cc438fc374e6799143f.

📒 Files selected for processing: 2
  • apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
  • packages/provider-opencode/src/server/v2/adapter.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

📝 Walkthrough

The OpenCode adapter now classifies provider.quota and provider.rate-limit execution failures as usage_limit. Tests check those cases and verify that other provider errors remain provider_error.

Changes: OpenCode failure classification

Layer / File(s)Summary
Classify execution failures
packages/provider-opencode/src/server/v2/adapter.ts, apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts
The adapter maps provider.quota and provider.rate-limit to usage_limit; other error types remain provider_error. Tests check all three cases and verify the failed terminal event fields.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: juliusmarminge

Merge Risk: ⚪ Minimal · up to 08740

The change adds the required quota and rate-limit classification while preserving the provider-error fallback. OpenCode failures without reset times will not enter automatic recovery, consistent with the documented conditional contract; no actionable merge blocker remains.

### Architecture Summary

Architecture risk: 🔵 Low · up to 08740

The change affects 2 systems.

Changed systems: packages/provider-opencode, apps/server

Architecture concerns No architecture-level concerns identified.

Review details

Systems and components

  • observed — packages/provider-opencode (library) was modified; 1 changed file maps to changed impact.
  • observed — apps/server (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in apps/server/src/orchestration-v2/Adapters/OpenCode2AdapterV2.test.ts: Adds three execution-failure classification cases and asserts each produces a failed terminal event with the expected failure class, original code and message, and retryable: null.
  • observed — Modified behavior in packages/provider-opencode/src/server/v2/adapter.ts: The failure classification now maps provider.quota and provider.rate-limit event types to usage_limit instead of classifying every execution failure as provider_error.
Pre-merge checks: Passed 4
Check nameStatusExplanation
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Title checkPassedThe title clearly and concisely identifies the OpenCode quota-stop classification fix.
Description checkPassedThe description clearly explains the problem, the implementation, the scope, and detailed verification results. It links the related pull request and documents limitations and review evidence. It does…
Full details: Description check

Explanation

The description clearly explains the problem, the implementation, the scope, and detailed verification results. It links the related pull request and documents limitations and review evidence. It does not use the template headings and does not include an explicit maintainer approval comment, but the required information is mostly present.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Taking over this one. I will preserve your branch history and finish the typed quota classification with focused regression coverage and independent reviews.

Added 4 commits

  • test(opencode): cover typed execution failure classification518edc4
  • Merge commit '18f26cf179' into fix/opencode-usage-limita13112d
  • fix(opencode): classify quota stops at the adapter boundaryba1cf16
  • chore(opencode): keep quota fix focused08740fb