From 8d6870f96e5f58c217e52dbce867d920dd4ae1d9 Mon Sep 17 00:00:00 2001 From: Paco Cartones <253313177+pacocartones@users.noreply.github.com> Date: Sun, 23 Aug 2026 06:24:28 +0200 Subject: [PATCH] fix(analytics): classify opencode-go as a flat-rate subscription (#11199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Validated on the combined batch board over tip c92bd40b: static gates clean (changelog, file-size 158 frozen, complexity 2626<=2774, cognitive 1183<=1223, dead-code 409<=416), typecheck:core clean, 70 focused tests green (PR suites 49/49 + auth/combo neighbors 21/21). opencode-go joins FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS — cost analytics stop pricing a flat 0 subscription at metered aggregator rates (3.35 reported vs 0 actual). Same pattern as #10774. Fixes #11149. Thank you @pacocartones! --- .../fixes/11149-opencode-go-flat-rate.md | 1 + src/lib/usage/flatRateProviders.ts | 5 +++++ tests/unit/flat-rate-cost-5552.test.ts | 22 +++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 changelog.d/fixes/11149-opencode-go-flat-rate.md diff --git a/changelog.d/fixes/11149-opencode-go-flat-rate.md b/changelog.d/fixes/11149-opencode-go-flat-rate.md new file mode 100644 index 0000000000..7aa63ad455 --- /dev/null +++ b/changelog.d/fixes/11149-opencode-go-flat-rate.md @@ -0,0 +1 @@ +- **fix(analytics):** `opencode-go` is now classified as a flat-rate subscription, so cost analytics shows $0 for it instead of billing every call at the underlying model’s metered rate — it resells GLM, Kimi, Grok, DeepSeek, MiniMax, Qwen and GPT-5.x under one flat monthly fee, which made the overstatement large rather than marginal ([#11149](https://github.com/diegosouzapw/OmniRoute/pull/11149)) — thanks @electrumguy diff --git a/src/lib/usage/flatRateProviders.ts b/src/lib/usage/flatRateProviders.ts index 8d3eec2c5d..3454b9b391 100644 --- a/src/lib/usage/flatRateProviders.ts +++ b/src/lib/usage/flatRateProviders.ts @@ -46,6 +46,11 @@ const FLAT_RATE_SUBSCRIPTION_PROVIDER_IDS: ReadonlySet = new Set([ "glm-cn", // GLM Coding (China) plan "claude", // Claude Code plan (OAuth-only — a Claude Pro/Max subscription) "cc", // Claude Code plan (alias id — same connection, shares the `cc` pricing rows) + // OpenCode Go subscription (https://opencode.ai/go) — a flat monthly fee. It is an + // aggregator reselling GLM, Kimi, Grok, DeepSeek, MiniMax, Qwen and GPT-5.x, so + // per-token rows price each call at the UNDERLYING model's metered rate and the + // analytics overstatement is large rather than marginal (#11149). + "opencode-go", ]); /** diff --git a/tests/unit/flat-rate-cost-5552.test.ts b/tests/unit/flat-rate-cost-5552.test.ts index 2df378ee3e..61ad9847b1 100644 --- a/tests/unit/flat-rate-cost-5552.test.ts +++ b/tests/unit/flat-rate-cost-5552.test.ts @@ -25,6 +25,7 @@ test("isFlatRateProvider: dedicated subscription / coding-plan providers are fla "glm-cn", "claude", "cc", + "opencode-go", ]) { assert.equal(isFlatRateProvider(id), true, `${id} should be flat-rate`); } @@ -83,6 +84,27 @@ test("computeCostFromPricing: opt-in only — flat-rate provider WITHOUT the fla assert.equal(computeCostFromPricing(PRICING, TOKENS, { provider: "chatgpt-web" }), 3); }); +test("#11149: opencode-go is a flat-rate subscription, not metered", () => { + // opencode-go (https://opencode.ai/go) is a $10/month flat subscription that + // resells GLM, Kimi, Grok, DeepSeek, MiniMax, Qwen and GPT-5.x. Because it is + // an aggregator, every call was priced at the UNDERLYING model's metered rate, + // so the overstatement is large rather than marginal (a reported ~$13.35 for a + // month actually billed at $10 flat). It is api-key auth, so it is not covered + // by the dynamic WEB_COOKIE_PROVIDERS branch and needs the explicit id. + assert.equal(isFlatRateProvider("opencode-go"), true); + assert.equal( + computeCostFromPricing(PRICING, TOKENS, { provider: "opencode-go", flatRateAsZero: true }), + 0 + ); + // Still opt-in: without the flag the per-request estimate is unchanged. + assert.equal(computeCostFromPricing(PRICING, TOKENS, { provider: "opencode-go" }), 3); +}); + +test("#11149: sibling opencode ids keep their own billing semantics", () => { + // Only the Go subscription is flat-rate. The keyless `opencode` provider is a + // different id and must not be swept in by a prefix-style match. + assert.equal(isFlatRateProvider("opencode"), false); +}); test("computeCostFromPricing: metered provider with the flag still estimates", () => { assert.equal( computeCostFromPricing(PRICING, TOKENS, { provider: "openai", flatRateAsZero: true }),