GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(core): read OpenCode Console usage limits and classify budget refusals by adamdotdevin · Pull Request #58694 · anomalyco/opencode

Conversation

@adamdotdevin

@adamdotdevin adamdotdevin commented Oct 24, 2026 •
edited by opencode-agent Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This is the data layer for the usage limits designs (Figma: Desktop Q4 2026 → Usage), which add a Usage limits dialog, a header indicator, timeline notices and model picker usage. The UI PRs build on this one and target beta.

Usage limits endpoint

GET /api/experimental/usage/limits (client.usage.limits({ location })) returns the OpenCode Go allowance and Console budgets of the OpenCode Console workspace the location is signed in to. It returns data: null when the location isn't signed in.

{
  "workspace": { "id": "wrk_…", "name": "Anomaly", "usageURL": "https://opencode.ai/console/wrk_…/activity/overview" },
  "go": {                                   // only where the member subscribes to Go
    "rolling": { "percent": 42, "limited": false, "resetsAt": 1792890000000 },
    "weekly":  { "percent": 18, "limited": false, "resetsAt": 1793232000000 },
    "monthly": { "percent": 100, "limited": true, "resetsAt": 1793491200000 }
  },
  "budgets": [
    {
      "id": "rule_…", "limit": 20, "spent": 15,
      "scope": "each", "per": "model",       // per member or combined; across the set or per model
      "coverage": "models",                  // "all": every model and billable service
      "models": [{ "providerID": "opencode", "modelID": "gpt-6-astra", "name": "GPT-6 Astra", "spent": 15 }],
      "vendors": ["OpenAI"],                 // what the budget counts: vendors by name,
      "inputPriceAtLeast": 3,                //   a price floor (USD per 1M input tokens),
      "picked": false,                       //   or models picked one by one
      "shared": false,                       // the entire workspace pools it
      "resetsAt": 1793491200000
    }
  ]
}
  • Core's UsageLimits service resolves the location's active OpenCode Console credential and reads two endpoints in parallel:
    • Console's GET /api/policies/current-budgets, with x-org-id.
    • Go's GET /zen/go/v1/usage on the Console's origin, with x-opencode-org-id.
  • Console refuses budgets to a service account's key and Go refuses non-subscribers (both 403). Those mean "nothing to show", not errors. Other failures return 503.
  • Budget models carry OpenCode's own provider and model IDs, so the model picker can find limited models.
  • The Console URL and auth headers move from the OpenCode Console plugin into ConsoleAccess, so the plugin and the new service share one implementation, including the retired-host rewrite.

Budget refusals

Console now refuses requests over a budget with a typed BudgetLimitError, which says what the budget covers. In Google's envelope, that's in an ErrorInfo detail.

  • packages/ai classifies it as quota, so it isn't retried as a rate limit.
  • toSessionError reports provider.model-budget-limit for a budget on the requested model and provider.budget-limit for one on all model use. This matches the two timeline notices in the design.

Depends on

anomalyco/opencode-console#4283 adds these fields and errors. It's merged to Console dev and deployed there; production gets it with the next promotion. anomalyco/opencode-console#4288 adds vendors, inputPriceAtLeast and picked, which the revised designs use to say what a budget counts. Until then, production Console's current-budgets lacks the new fields. Members with an all-spend budget would get a 503 from this endpoint, while members without budgets are unaffected. Nothing calls the endpoint until the UI PRs.

Tests

  • packages/core/test/usage-limits.test.ts: the requests sent to Console and Go (headers per service), mapping, 403s as nothing to show, and failures as unavailable.
  • packages/server/test/usage.test.ts: the route, null for a signed-out location, and a 503 for an unavailable Console.
  • packages/core/test/session-error.test.ts: model versus all-spend budget refusals, in both envelopes.
  • packages/ai/test/provider-error.test.ts: BudgetLimitError classifies as quota, in both envelopes.
  • Each new assertion was checked to go red by breaking the behaviour it names. bun run check passes, and so do the Console plugin and client suites.

Verified against dev Console

I ran this branch with isolated state, signed in to a temporary dev workspace by device login (--answer server=https://dev.opencode.ai/console). That workspace had a combined all-spend budget for the entire workspace and a per-member budget on DeepSeek V4 Flash and Grok 4.7.

  • opencode api experimental.usage.limits returned both budgets, with the expected coverage, shared, models (by OpenCode provider ID), limits, spend and reset time. There was no Go section, because the live Go endpoint refuses (403) a workspace without a subscription.
  • At $0 on the model budget, a DeepSeek V4 Flash prompt failed straight away with provider.model-budget-limit. Console's body was BudgetLimitError with metadata: { coverage: "models", resetsAt: "2026-11-01T00:00:00.000Z" }.
  • At $0 on the workspace budget, the same prompt failed with provider.budget-limit (coverage: "all").
  • Not checked live: the Google envelope, because no Gemini model is routed on dev. The Console and OpenCode unit tests above cover it.

Added by the opencode bot (AI-generated).

Related: #57072, #42776, #49693

Public API: adds vendors, inputPriceAtLeast and picked to UsageLimits.Budget in GET /api/experimental/usage/limits (backwards compatible)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@adamdotdevin
feat(core): read OpenCode Console usage limits and classify budget re…
1934f12
…fusals

Adds GET /api/experimental/usage/limits (client.usage.limits): the OpenCode Go
allowance and Console budgets of the OpenCode Console workspace a location is
signed in to, or null when it isn't. Core's UsageLimits service reads Console's
current budgets and Go's usage endpoint with the location's Console credential.

Console now refuses requests over a budget with BudgetLimitError. It classifies
as quota rather than a retryable rate limit, and the session error says whether
a budget on the requested model (provider.model-budget-limit) or one on all
model use (provider.budget-limit) refused it.

The Console URL and auth headers move from the OpenCode Console plugin into
ConsoleAccess so both use one implementation.
opencode-agent[bot]
opencode-agent Bot reviewed Oct 24, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sound. I ran the server from source: the new route returns data: null for a location that isn't signed in. The new core, ai, server and client tests pass, and tsc -b is clean on core (with tests), server and client. I couldn't exercise a signed-in Console without credentials; the mocked tests cover the requests, the mapping and the 403s.

Public API: adds GET /api/experimental/usage/limits (experimental.usage.limits, client.usage.limits({ location })), the UsageLimits.* schemas in @opencode/schema/usage-limits and the OpenAPI spec, and two new session error types, provider.budget-limit and provider.model-budget-limit. Responses that used to come back as provider.quota now get one of these when the body contains BudgetLimitError. Everything is additive. The only behaviour change: anything matching on provider.quota for Console budget refusals will now see the new types.

One concern, inline: if either upstream read fails, the whole endpoint fails.

Related: #57072, #42776, #49693

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/usage-limits.ts
const workspaceID = credential.metadata?.orgID
if (typeof workspaceID !== "string") return undefined
const server = ConsoleAccess.server(credential)
const [budgets, go] = yield* Effect.all(

@opencode-agent opencode-agent Bot Oct 24, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is all-or-nothing: a Go /zen/go/v1/usage outage hides the member's budgets, and a budgets decode failure hides Go. The second case will happen against production Console until #4283 is promoted, for anyone with an all-spend budget. Since the two reads are independent, could each one degrade on its own? For example, leave out go or return no budgets, and only return a 503 when both fail. That way the header indicator keeps showing whatever data it does have.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@adamdotdevin
feat(core): say what each usage budget counts
f06ac29
Budgets carry the vendors (by name), input price floor and whether models are
picked one by one, from anomalyco/opencode-console#4288, so the app can name a
budget "Anthropic models" or "$3+ per 1M input" in the member's language.
opencode-agent[bot]
opencode-agent Bot reviewed Oct 24, 2026
View reviewed changes

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new fields map correctly. The updated core and server tests pass, and tsc -b is clean on core, server and client. The earlier point about the endpoint being all-or-nothing isn't addressed yet.

Public API: adds vendors: string[], inputPriceAtLeast?: Money.USDPerMillionTokens and picked: boolean to UsageLimits.Budget, both in the experimental GET /api/experimental/usage/limits response and in the OpenAPI spec. These are additive, and the endpoint is unreleased.

One new concern, inline: the new fields are required when decoding Console's response.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread packages/core/src/usage-limits.ts
spentDollars: Schema.optional(Schema.Finite),
}),
),
vendors: Schema.Array(Schema.Struct({ id: Schema.String, name: Schema.String })),

@opencode-agent opencode-agent Bot Oct 24, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vendors and picked are required here, so any Console without anomalyco/opencode-console#4288 fails to decode every budget, not only all-spend ones. Until it's deployed, any member with a budget at all would get a 503. Could these decode as optional, with [] and false as defaults, so the endpoint doesn't depend on that deploy?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
This was referenced Oct 24, 2026
feat(app): show Console budgets and Go usage where they stop you #58714
Merged
feat(tui): show OpenCode Console usage limits #58731
Merged
@adamdotdevin
adamdotdevin merged commit e42f6d1 into dev Oct 24, 2026
37 of 38 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@adamdotdevin
adamdotdevin deleted the console-usage branch October 24, 2026 16:13
@adamdotdevin adamdotdevin mentioned this pull request Oct 24, 2026
refactor(core): keep Go allowance out of messages and sessions #58765
Merged
3 of 6 tasks
@kitlangton kitlangton mentioned this pull request Oct 24, 2026
fix: type the Go and ChatGPT usage limits #57897
Merged
This was referenced Oct 25, 2026
Session failures: retry-after countdown and usage-limit error types opencode-mobile/opencode-mobile#832
Closed
#832 Retry-after countdown and usage-limit actions on session failures opencode-mobile/opencode-mobile#834
Merged
@amrkmn amrkmn mentioned this pull request Oct 27, 2026
opencode 2.2.0 amrkmn/homebrew-tap#1182
Closed
1 task
@nalpri nalpri mentioned this pull request Oct 27, 2026
feat(quota): read OpenCode Go usage limits through the OpenCode CLI nalpri/ai-usage#77
Merged
@opencode-agent opencode-agent Bot mentioned this pull request Oct 27, 2026
[FEATURE]: Persist the Go allowance a session used (assistant message + session_v2) so clients can show a per-session figure #59653
Open
1 task done
@github-actions github-actions Bot mentioned this pull request Oct 28, 2026
Tool release: OpenCode 2 v2.2.0 (was v2.1.4) agent-sh/agnix#1737
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 28, 2026
[FEATURE]: Improve Auto Router Error Messaging and Model Status Indicators #47893
Open
1 task done
@thoratou thoratou mentioned this pull request Oct 29, 2026
tui: OpenCode Go sessions show no spend in 2.2.0 #60156
Closed
@opencodejr opencodejr Bot mentioned this pull request Oct 31, 2026
[FEATURE]: Surface Meta Model API usage quota #60981
Closed
1 task done
@opencodejr opencodejr Bot mentioned this pull request Nov 23, 2026
feat: show Codex subscription limits in /usage #65754
Closed
3 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@opencode-agent opencode-agent[bot] opencode-agent[bot] left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@adamdotdevin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.