Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix: an OpenCode Go limit holds the Go models, not the free OpenCode models on the same sign-in

AdityaUmale65a6817dee50
diff --git a/server/drivers/acp/opencode-go.test.ts b/server/drivers/acp/opencode-go.test.ts
index 3e99a58acd..850bdea725 100644
--- a/server/drivers/acp/opencode-go.test.ts
+++ b/server/drivers/acp/opencode-go.test.ts
@@ -384,6 +384,24 @@ describe("OpenCode catalog", () => {
expect(openCodeLimitFacts(said), "a refusal that names no model holds just the model scope").toEqual({ limit: "model" });
});
+ // OpenCode Go's weekly allowance is the Go subscription's alone: Zen's free models on the same login keep working, so a
+ // free model there is still a backup when a Go model runs out.
+ it("holds only the Go models when a Go model meets the Go allowance, never Zen's free models", () => {
+ parseOpenCodeModelsOutput([
+ "opencode/deepseek-v4.1-flash-free", JSON.stringify({ cost: { input: 0, output: 0 } }),
+ "opencode-go/glm-5.3", JSON.stringify({ cost: { input: 1, output: 2 } }),
+ "opencode-go/minimax-m3", JSON.stringify({ cost: { input: 1, output: 2 } }),
+ ].join("\n"));
+ for (const said of ["OpenCode Go weekly usage limit reached", "Internal error: GoUsageLimitError: the Go allowance is used up"]) {
+ const facts = openCodeLimitFacts(said, "opencode-go/minimax-m3");
+ expect(facts.limit, said).toBe("model");
+ expect(facts.limitModels).toEqual(expect.arrayContaining(["opencode-go/minimax-m3", "opencode-go/glm-5.3"]));
+ expect(facts.limitModels).not.toContain("opencode/deepseek-v4.1-flash-free");
+ }
+ expect(openCodeLimitFacts("OpenCode Go weekly usage limit reached", "opencode/big-pickle"), "a limit met by another model still holds the account")
+ .toEqual({ limit: "engine" });
+ });
+
it("classifies OpenCode 2's authentication refusal and leaves real internal errors alone", () => {
expect(classifyOpenCodeError({ code: -32000, message: "Authentication required: provider authentication required", data: {} }))
.toBe("invalid_credentials");
diff --git a/server/drivers/acp/opencode-go.ts b/server/drivers/acp/opencode-go.ts
index 4216a4c7e9..e29ea1b4d2 100644
--- a/server/drivers/acp/opencode-go.ts
+++ b/server/drivers/acp/opencode-go.ts
@@ -748,10 +748,18 @@ const ACCOUNT_ERROR_TEXT: ReadonlyArray<readonly [RegExp, AccountErrorCode]> = [
* refusal holds that login's free models and leaves the account available. */
const FREE_MODEL_LIMIT = /\bfree(?:UsageLimitError|\s+usage\s+limit)\b/iu;
+/** OpenCode Go's subscription models: its weekly or monthly allowance holds them all, never Zen's free models on the same
+ * login, which have an allowance of their own. */
+const GO_PROVIDER = "opencode-go/";
+
/** How far a usage limit OpenCode reported reaches: one provider's shared free allowance (with the free models that
- * allowance holds), or the whole account. */
+ * allowance holds), the Go subscription's models, or the whole account. */
export function openCodeLimitFacts(text: string, model?: string): { limit: "engine" | "model"; limitModels?: string[] } {
- if (!FREE_MODEL_LIMIT.test(text)) return { limit: "engine" };
+ if (!FREE_MODEL_LIMIT.test(text)) {
+ if (!model?.startsWith(GO_PROVIDER)) return { limit: "engine" };
+ const listed = [...lastSuccessfulCatalog.values()].flatMap((catalog) => catalog.options.map((option) => option.id));
+ return { limit: "model", limitModels: [...new Set([model, ...paidModels, ...listed].filter((id) => id.startsWith(GO_PROVIDER)))] };
+ }
const provider = model?.includes("/") ? model.slice(0, model.indexOf("/")) : "";
const shared = provider ? [...freeModels].filter((id) => id.startsWith(`${provider}/`)) : [];
const models = [...new Set(model ? [model, ...shared] : shared)];