From cf0de01e2a98bec62377f37b162a8eabcb5a99aa Mon Sep 17 00:00:00 2001 From: geoqiao <105639506+geoqiao@users.noreply.github.com> Date: Fri, 9 Oct 2026 00:25:32 +0800 Subject: [PATCH] cursor 0.2.1: an id 0.1.x listed, at an effort only its other branch has, goes as its own branch's nearest, not as the default's id with parameters that contradict it (review of #51) (#54) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An old id names a branch of a model's variants (claude-opus-5 is the Opus 5 without thinking). When the effort asked for exists only in the other branch, no variant matched and the request went as the default's legacySlug with the parameters it had been given: cursor/claude-opus-5 at xhigh went as claude-opus-5-thinking-high with thinking=false, effort=xhigh. On this account Opus 5 without thinking stops at high, so it happens today: 40 of 5040 old id × effort × fast combinations, all claude-opus-5. 0.1.11 sent claude-opus-5-high there. Now, for an old id, a request no variant matches goes as the variant of its own branch (every parameter but the effort as asked) at the nearest effort it has (branch()): claude-opus-5 at xhigh or max is claude-opus-5-high, -fast at xhigh is claude-opus-5-high-fast, as 0.1.11 sent them. Where the default differs from what is asked in the effort alone, the effort still goes as asked. A listed id is not changed. context.test.mjs adds a picker shaped like this account's Opus 5 and checks those cases and that every id sent agrees with its parameters (which holds where the default's branch is complete, as in this picker; see Not covered); it fails on 8cd5a0f's index.mjs. HOME=$(mktemp -d) bun test packages/cursor: 49 pass, 0 fail; check.mjs cursor passes. Offline against this account's picker and usable list: the contradicting requests go from 40 to 0. With a real Cursor account, this version installed into magpie (packed from this code plus one temporary line logging what request() returns): cursor/claude-opus-5 at reasoning_effort xhigh (max_tokens 16) went as claude-opus-5-high with thinking=false, context=300k, effort=high, fast=false, maxMode=false, and answered 200 ("ok", 14 in / 4 out, 5.2s; magpie's usage log: effort xhigh, status 200). On 0.2.0 the contradicting request cursor/claude-opus-5-low at xhigh also answered 200, so it failed silently. Not covered. branch() steps aside when what is asked differs from the default variant in the effort alone, so that an effort goes as asked, as for a listed model (the existing claude-opus-5-5-xhigh test expects effort=xhigh). So when the branch that stops short is the default's own, the request still goes as the default's slug with the effort asked: with a default of m-high (no thinking, low to high) and a thinking branch up to max, m at xhigh goes as m-high with effort=xhigh. Dropping that early return fixes it (effort=high) and changes that one assertion; left for the maintainer to decide. On this account no model's default branch is the shorter one (of 20 models with two or more branches, only non-default branches stop short: claude-opus-5's without thinking, and gpt-5.4's fast one after the usable list). --- packages/cursor/context.test.mjs | 41 ++++++++++++++++++++++++++++++++ packages/cursor/index.mjs | 22 ++++++++++++++++- packages/cursor/package.json | 2 +- 3 files changed, 63 insertions(+), 2 deletions(-) diff --git a/packages/cursor/context.test.mjs b/packages/cursor/context.test.mjs index 985cb39..87d738d 100644 --- a/packages/cursor/context.test.mjs +++ b/packages/cursor/context.test.mjs @@ -197,3 +197,44 @@ test("a variant the usable list says the account hasn't got is neither offered n expect(q("cursor-grok-4.6", "low")).toEqual(["cursor-grok-4.6-high", false, { effort: "high" }]) expect(q("composer-2.5", "", true)).toEqual(["composer-2.5-fast", false, { fast: "true" }]) }) + +// Opus 5 as Cursor has it: without thinking, low to high; with it, up to +// max, the default. An id of the branch without thinking asked at xhigh +// fitted nothing and went as the default's id with thinking=false, a name +// and parameters at odds (review of #51). +const OPUS5 = { + name: "claude-opus-5", clientDisplayName: "Claude Opus 5", contextTokenLimit: 300000, contextTokenLimitForMaxMode: 1000000, supportsNonMaxMode: true, + parameterDefinitions: [{ id: "thinking", parameterType: bool }, { id: "context", parameterType: en("300k") }, { id: "effort", parameterType: en("low", "medium", "high", "xhigh", "max") }, { id: "fast", parameterType: bool }], + variants: [ + ...["low", "medium", "high"].flatMap((e) => [v({ thinking: "false", context: "300k", effort: e, fast: "false" }, { legacySlug: "claude-opus-5-" + e }), v({ thinking: "false", context: "300k", effort: e, fast: "true" }, { isMaxMode: true, legacySlug: "claude-opus-5-" + e + "-fast" })]), + ...["low", "medium", "high", "xhigh", "max"].flatMap((e) => [v({ thinking: "true", context: "300k", effort: e, fast: "false" }, { legacySlug: "claude-opus-5-thinking-" + e, ...(e === "high" ? { isDefaultNonMaxConfig: true } : {}) }), v({ thinking: "true", context: "300k", effort: e, fast: "true" }, { isMaxMode: true, legacySlug: "claude-opus-5-thinking-" + e + "-fast" })]), + ], +} + +test("an id of Cursor's own at an effort its branch hasn't goes as that branch's nearest, not the default's id", async () => { + fakeAPI([OPUS5]) + const raw = await usable(tok()) + const q = (id, effort = "", fast) => { + const r = request(raw, id, effort, fast) + return [r.id, r.maxMode, Object.fromEntries(r.params.map((x) => [x.id, x.value]))] + } + // without thinking it stops at high + expect(q("claude-opus-5-low", "xhigh")).toEqual(["claude-opus-5-high", false, { thinking: "false", context: "300k", effort: "high", fast: "false" }]) + expect(q("claude-opus-5-medium-fast", "max")).toEqual(["claude-opus-5-high-fast", true, { thinking: "false", context: "300k", effort: "high", fast: "true" }]) + // the 0.1.x family without thinking + expect(q("claude-opus-5", "max")).toEqual(["claude-opus-5-high", false, { thinking: "false", context: "300k", effort: "high", fast: "false" }]) + expect(q("claude-opus-5-fast", "xhigh")).toEqual(["claude-opus-5-high-fast", true, { thinking: "false", context: "300k", effort: "high", fast: "true" }]) + // with thinking at xhigh, asked not to think: no thinking, at its nearest effort + expect(q("claude-opus-5-thinking-xhigh", "none")).toEqual(["claude-opus-5-high", false, { thinking: "false", context: "300k", effort: "high", fast: "false" }]) + // what the branch has still goes as asked, and the other branch is untouched + expect(q("claude-opus-5-low", "high")[0]).toBe("claude-opus-5-high") + expect(q("claude-opus-5-thinking-low", "max")[0]).toBe("claude-opus-5-thinking-max") + // every id sent agrees with its parameters + const slug = new Map(OPUS5.variants.map((x) => [x.legacySlug, Object.fromEntries(x.parameterValues.map((p) => [p.id, p.value]))])) + for (const id of [...slug.keys(), "claude-opus-5", "claude-opus-5-fast", "claude-opus-5-thinking", "claude-opus-5-thinking-fast"]) + for (const effort of ["", "none", "low", "medium", "high", "xhigh", "max"]) + for (const fast of [undefined, true]) { + const [sent, , params] = q(id, effort, fast) + expect([id, effort, fast, params]).toEqual([id, effort, fast, { ...params, ...slug.get(sent) }]) + } +}) diff --git a/packages/cursor/index.mjs b/packages/cursor/index.mjs index 8990877..c9655f3 100644 --- a/packages/cursor/index.mjs +++ b/packages/cursor/index.mjs @@ -592,7 +592,7 @@ function pick(entry, effort, fast, seed) { const have = valuesOf(v) return Object.keys({ ...have, ...want }).every((k) => have[k] === undefined || want[k] === undefined || have[k] === want[k]) } - const v = entry.variants.find(same) ?? (entry.partial ? nearest(entry.variants, want) : undefined) + const v = entry.variants.find(same) ?? (seed ? branch(entry, want) : undefined) ?? (entry.partial ? nearest(entry.variants, want) : undefined) const params = Object.entries(v ? { ...want, ...valuesOf(v) } : want).map(([id, value]) => ({ id, value })) // no variant: Max Mode when the size is more than Cursor allows outside it const maxMode = v ? needsMax(entry.model, v) : needsMax(entry.model, def) || tokensOf(entry.size) > (entry.model.contextTokenLimit || Infinity) @@ -603,6 +603,26 @@ function pick(entry, effort, fast, seed) { return { id, params, maxMode } } +// branch is, for an id of Cursor's own asked at an effort no variant has +// with the rest of its parameters (claude-opus-5-low at xhigh: Opus 5 +// without thinking stops at high), the variant with those parameters at the +// nearest effort it has, not the default's id with parameters that +// contradict it (claude-opus-5-thinking-high with thinking=false). Where +// the default differs from what is asked in the effort alone, the effort +// goes as asked, as for a listed model. +function branch(entry, want) { + if (!entry.pid || entry.pid === "thinking") return undefined + const def = valuesOf(entry.def) + if (Object.keys(want).every((k) => k === entry.pid || k === "context" || def[k] === undefined || def[k] === want[k])) return undefined + const vs = entry.variants.filter((v) => { + const have = valuesOf(v) + return entry.pid in have && Object.keys(want).every((k) => k === entry.pid || have[k] === undefined || have[k] === want[k]) + }) + const level = (x) => (x === "extra-high" ? "xhigh" : x) + const at = fitEffort(level(want[entry.pid]), vs.map((v) => level(valuesOf(v)[entry.pid]))) + return at ? vs.find((v) => level(valuesOf(v)[entry.pid]) === at) : undefined +} + // fitEffort is the nearest effort a model has to the one asked for; max // for ultra, and none only when asked. function fitEffort(want, levels) { diff --git a/packages/cursor/package.json b/packages/cursor/package.json index 846a7bc..928c7c5 100644 --- a/packages/cursor/package.json +++ b/packages/cursor/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-cursor-auth", - "version": "0.2.0", + "version": "0.2.1", "description": "Cursor subscriptions (Pro, Pro+, Ultra, Teams) in OpenCode and magpie, through the API cursor-agent talks to", "type": "module", "main": "./index.mjs",