CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

OpenCode Go Usage calculation incorrect

Open dl-web-dev opened this issue 4 months ago • 3 comments

OpenCode Go usage does not appear to be reporting accurately. Sorta. View screenshots below:

Image Image

Now from my understanding, it may be related to some models costing 4x of your usage such as DeepSeek v4 Pro. However I may be entirely off with that. The total spend amount does match what OpenCode is showing, its just the remaining quota that doesn't match.

Was just curious if it would be possible to adjust for this or if this is expected behavior.

dl-web-dev avatar Aug 01 '26 15:08 dl-web-dev

Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 2, 2026, 7:29 AM ET / 11:29 UTC.

Summary Current main contains the targeted OpenCode Go quota-window correction and a contributor supplied a redacted current-main CLI result showing web and auto values agree. This issue remains open under the repository’s conservative onboarding policy until the fix is released and the reporter’s weighted-model account can confirm the observed remaining quota.

Reproducibility: yes. for the former mechanism: focused current-main tests recreate the drifting local monthly estimate and verify replacement by server quota values. The reporter’s exact weighted-model account still needs a direct retest.

Maintainer decision needed

Question Recommendation
Should the merged OpenCode Go quota-overlay fix be included in the next release before this report is resolved? Release and request confirmation: Include the existing fix in the next release and ask the reporter to retest the weighted-model account on that build before resolving the report.

Why: Current source and a current-main live run support the code path, but release timing and whether affected-account confirmation is required before resolving the report are release-owner decisions.

Next step No additional repair PR is warranted because the focused fix is already merged; the remaining action is a release-inclusion decision and a reporter-account confirmation.

Review details

Best possible solution:

Ship the existing authoritative web-window overlay in the next release, then confirm the reporter’s affected account reports the provider’s remaining quota without a separate local-cost adjustment.

Do we have a high-confidence way to reproduce the issue?

Yes for the former mechanism: focused current-main tests recreate the drifting local monthly estimate and verify replacement by server quota values. The reporter’s exact weighted-model account still needs a direct retest.

Is this the best way to solve the issue?

Yes. Using authenticated server billing windows for quota percentages and resets while retaining local-only daily cost history is narrower and more maintainable than attempting to infer weighted-model billing locally.

AGENTS.md: found and applied where relevant.

Remaining risk / open question:

  • v0.46.0 does not contain the correction, so users on the current release can still see the old local-estimate mismatch.
  • The exact weighted-model account described in the report has not yet been retested after the current-main overlay change.

Codex review notes: model internal, reasoning high; reviewed against 41bc0141e5f1; fix evidence: commit cf7b74913366, main fix timestamp 2026-07-23T14:02:18-07:00.

Label changes

Label changes:

  • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
  • add clawsweeper:source-repro: Current issue advisory state selects this label.
  • add clawsweeper:no-new-fix-pr: Current issue advisory state selects this label.
  • add clawsweeper:needs-maintainer-review: Current issue advisory state selects this label.
  • remove issue-rating: 🐚 platinum hermit: Current issue advisory state no longer selects this label.
  • remove clawsweeper:needs-live-repro: Current issue advisory state no longer selects this label.

Label justifications:

  • P2: The issue affects provider quota accuracy for a bounded provider surface, while current main already contains the targeted correction.
  • impact:other: The report concerns inaccurate quota presentation rather than data loss, authentication, session state, or process availability.
Evidence reviewed

What I checked:

  • Current implementation: The local OpenCode Go strategy documents that its monthly window is an estimate and overlays server-reported quota windows whenever an existing session cookie is available; it returns the merged snapshot as local+web. (Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift:124, 41bc0141e5f1)
  • Regression coverage: Focused tests model the former mis-anchored 100% local monthly estimate and verify that the web overlay replaces it with the server’s 64% monthly value and server reset time while retaining local daily history. (Tests/CodexBarTests/OpenCodeGoWebOverlayTests.swift:53, 41bc0141e5f1)
  • Fix provenance: The behavior appears to originate with the targeted fix commit and was merged through pull request 2430; its parent history is present on current main. (Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift:132, cf7b74913366)
  • Documented product boundary: The OpenCode Go documentation explicitly says local monthly values can drift from the real billing cycle and that cached/manual-cookie web values overlay rolling, weekly, and monthly percentages and reset countdowns. (docs/opencode.md:32, 41bc0141e5f1)
  • Release provenance: The fix is on current main but is not reachable from v0.46.0; the current release therefore still predates the correction. (cf7b74913366)
  • Current-main live evidence: A redacted August 2, 2026 current-main CLI run in the discussion reported matching auto and web OpenCode Go quota windows; it also correctly notes that the reporter’s weighted-model account still needs a direct retest.

Likely related people:

  • aseelye: The merged OpenCode Go overlay pull request contains the focused commit that replaces drifting local quota estimates with authoritative web windows. (role: introduced the quota-overlay behavior; confidence: high; commits: cf7b74913366; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift, Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoUsageSnapshot.swift, Tests/CodexBarTests/OpenCodeGoWebOverlayTests.swift)
  • steipete: Merged the overlay pull request and subsequently maintained adjacent OpenCode Go cookie and source-order behavior. (role: recent area contributor and merger; confidence: high; commits: b036579b4b05, fa05d655ba62, 1912bb5642ed; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift, docs/opencode.md, docs/providers.md)
  • kiranmagic7: Implemented the local-first and scoped web strategy decisions that the overlay intentionally extends without changing the provider’s source-order contract. (role: recent adjacent contributor; confidence: medium; commits: a05b0b9d64de, 828aebff9130; files: Sources/CodexBarCore/Providers/OpenCodeGo/OpenCodeGoProviderDescriptor.swift)
How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

clawsweeper[bot] avatar Aug 01 '26 15:08 clawsweeper[bot]

Live reproduction on current main (contains overlay fix cf7b7491), run 2026-08-02 with a valid OpenCode Go session cookie (redacted, no identifiers):

$ codexbar usage --provider opencodego --source auto --format json
[{"provider":"opencodego","source":"web","usage":{"primary":{"usedPercent":16,"windowMinutes":300,"resetsAt":"2026-08-02T13:53:06Z"},"secondary":{"usedPercent":70,"windowMinutes":10080,"resetsAt":"2026-08-02T23:59:59Z"},"tertiary":{"usedPercent":35,"windowMinutes":43200,"resetsAt":"2026-09-01T16:44:44Z"}}}]

$ codexbar usage --provider opencodego --source web --format json
[{"provider":"opencodego","source":"web","usage":{"primary":{"usedPercent":16,"windowMinutes":300,"resetsAt":"2026-08-02T13:53:05Z"},"secondary":{"usedPercent":70,"windowMinutes":10080,"resetsAt":"2026-08-02T23:59:58Z"},"tertiary":{"usedPercent":35,"windowMinutes":43200,"resetsAt":"2026-09-01T16:44:44Z"}}}]

Findings:

  • On a current build, the remaining quota comes from the authoritative web quota windows (5h 16%, weekly 70%, monthly 35%, with server reset timestamps), replacing the local estimate that previously produced the mismatch; auto and web sources agree.
  • The reporter's weighted-model scenario (e.g. higher-cost models like DeepSeek v4 Pro) still needs a retest on the affected account with local rows present for full confirmation; the local+web merge path is covered by OpenCodeGoWebOverlayTests 13/13 and the OpenCodeGo suite 90/90.
  • The fix is on main only; v0.46.0 still contains the old local-estimate behavior.

Yuxin-Qiao avatar Aug 02 '26 10:08 Yuxin-Qiao

Fixed on main by #2430 (cf7b749133): OpenCode Go now uses the server's authoritative quota percentages and reset times instead of deriving remaining quota from local dollar cost. A live comparison showed Auto and Web returning identical values.

steipete avatar Aug 02 '26 20:08 steipete