t3code icon indicating copy to clipboard operation
t3code copied to clipboard

OpenCode Kimi Code plan instance shows OpenCode Go quota on the usage screen

Open matthias-scale opened this issue 4 weeks ago • 0 comments

Problem

An OpenCode provider instance configured for the Kimi Code plan (model kimi-code-plan-global/k3, or kimi-code/...) shows the host's OpenCode Go quota on the usage screen instead of its own.

packages/provider-opencode/src/server/usageLimits.ts always reads /zen/go/v1/usage with the stored OpenCode Go credentials, whatever model provider the instance uses. Two instances on one host (a Go instance and a Kimi instance) then get the same credential fingerprint. The dedupe merges them, so the Go cards are labelled with the Kimi instance's name and the Go instance disappears.

Observed on 0.1.7-nightly.20261101.4048: the Kimi instance showed Go session/weekly/monthly at 3% / 1% / 52% used. The Kimi Code plan itself was at 23% (5-hour) / 72% (monthly).

Expected

  • The Go reader only applies to instances using the opencode-go provider.
  • Kimi Code plan instances read GET https://api.kimi.com/coding/v1/usages (limit_5h, limit_month_total: used_ratio, reset_time).
  • An exhausted Kimi window only gates Kimi models, never unrelated OpenCode models.

Proposed fix

Branch ready if maintainers agree with the direction: matthias-scale:fix/usage-opencode-kimi. It picks the reader from the instance's merged OpenCode config (JSONC; config.json, opencode.json, opencode.jsonc, OPENCODE_CONFIG, OPENCODE_CONFIG_CONTENT), resolves the Kimi key from config, env reference or OpenCode's stored credentials, and keeps the Go reader when no model is configured. Covered by 160 passing package tests and checked against a live Kimi plan. I'll open the PR once this is triaged.

matthias-scale avatar Nov 02 '26 18:11 matthias-scale