Skip to content

fix(console): allow free Go models past quota - #44306

Open
opencode-agent[bot] wants to merge 1 commit into
devfrom
free-go-model
Open

fix(console): allow free Go models past quota#44306
opencode-agent[bot] wants to merge 1 commit into
devfrom
free-go-model

Conversation

@opencode-agent

Copy link
Copy Markdown
Contributor

Summary

  • classify Go models as free when every configured base and 200K token rate is zero
  • keep free models on Go subscription billing without applying exhausted quota or balance fallback checks

Checks

  • bun typecheck (packages/console/app)
  • bun x prettier --check src/routes/zen/util/handler.ts
  • bun test (packages/console/app): 5 passed, 2 unrelated failures in existing Google usage normalization expectations (outputTokens expected 3, received 5)

Requested by: @fwang (Frank via Slack)

@Enough1122

Copy link
Copy Markdown

AI code review — automated review for reference, author can ignore or act on any point.

The intent reads clearly: zero-cost Go models should stay on lite billing without hitting the exhausted-quota / balance-fallback checks below (packages/console/app/src/routes/zen/util/handler.ts, ~lines 911–916). A few things worth tightening:

  1. Vacuous "free" classification. Object.values(modelInfo.cost).every((cost) => cost === 0) returns true when modelInfo.cost is an empty object {}. If a model can ever reach this path with missing/unset pricing, it gets classified as free and bypasses quota validation entirely. If that's possible in practice, guard with something like Object.keys(modelInfo.cost).length > 0 && ....

  2. costPeak is not considered. The free check inspects cost and cost200K but ignores costPeak. A model with all-zero base rates but a nonzero peak rate would be treated as free while still being charged peak pricing on the usage path (~line 1049). Probably not reachable for current Go models, but folding (!modelInfo.costPeak || modelInfo.costPeak === 0) into the predicate makes the invariant explicit.

  3. No test covers the new branch. The PR description lists existing suites passing, but nothing exercises the new classification. Consider extracting the predicate into a small exported helper (similar to the pricing.ts module pattern) so it can be unit-tested directly — e.g., free-with-200K-absent, free-with-zero-200K, non-free-with-nonzero-cost, and the empty-cost-object edge from point 1.

  4. Confirm scope: returning "lite" skips both quota exhaustion and the balance fallback. That matches the title ("allow free Go models past quota"), just confirming it's also intended for workspaces with no balance at all, since these requests will now always succeed unmetered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants