Skip to content

Show OpenCode Go plan usage in oxa status and the oxc widget #62

Open

Description

@n0rpan

Owner request O-396 (2026-11-17).

OpenCode serves the Go plan limits at GET https://opencode.ai/inference/go/v1/usage (undocumented; found 2026-11-17 with a read-only key): usage.{rolling,weekly,monthly}.{status,percent,resetsAt}.

Scope:

  • oxa: /usage and oxa status show Go plan usage (three bars + reset times) when a Go model is configured; cached for 60 s; failures show 'unavailable', never block a request.
  • Gateway: optional soft pacing setting (e.g. warn at 80% weekly, prefer a configured fallback model above a user-set threshold). Off by default; nothing enforced.
  • Key: use the configured OpenCode key; if it lacks Usage read, allow an optional separate read-only key in the protected key store (never in settings files or logs).
  • oxc desktop widget: same three bars next to the other provider balances (O-312).
  • Tests with a fake endpoint: shape parsing, missing/changed fields degrade to 'unavailable', no key in output.
  • Because the endpoint is undocumented, keep the parser tolerant and fall back to summing per-response opencode.allowance.

Activity

  1. oxa-agent commented on Nov 18, 2026

    @oxa-agent
    Contributor

    N0 / Work3, preparing the #100 Go window input. The issue records the endpoint and rolling/weekly/monthly field names. If the original redacted receipt is already available, please supply the JSON types/units of percent and resetsAt, and whether status has an explicit limited/exhausted value. Field names, types and synthetic examples are sufficient. No new live request or credential read. Plan: typed, bounded gateway observation using the existing protected Go key reader and HTTP pool; one status refresh path independent of inference. The projected rows carry only percent, reset, observation time and availability, with no inferred allowance from stale data. Work3 retains the existing Lead Usage renderer and host-local clocks.

    Public wire evidence now answers the shape question. The OpenCode handler and an actual published response for the inference route establish numeric used percentages, ISO reset instants and ok / rate-limited status. oxstack/ox-llm#1403 at f4cd5a38 returns that typed status and rounds fractional resets up. Work3 can use it as the observation input. Unknown or stale state supplies no scheduling room. The gateway did not contact the provider.

  2. oxa-agent commented on Nov 18, 2026

    @oxa-agent
    Contributor

    oxstack/ox-llm#1403 landed at b4483393fcf9b51b3141107ee3544183af802e05 with green merge-group checks. Its follow-up #1429 adds an in-memory Usage observation for the existing Go account. Gateway::opencode_plan_observation(timeout, max_age, cancel) supplies the typed windows and their original acquisition time. The default status read uses 60 seconds. The caller can supply the protected owner's freshness policy. Expired windows, changed credentials and failed refreshes do not reuse stale data. Work3 retains Usage presentation; optional read-only credential and per-response allowance fallback remain open. The tests use loopback only.

  3. n0rpan commented on Nov 19, 2026

    @n0rpan
    ContributorAuthor

    Triage 2026-11-19: this issue is now tracked in #158 (Cluster: Usage, budgets and the desktop panel, priority P1), planned PR 1: "Status envelope and usage". It will be fixed there together with its related issues, not one by one.

  4. transferred this issue fromon Nov 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions