@magpie-community/opencode-qoder-auth 0.2.54 → 0.2.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -1
  2. package/index.mjs +16 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -138,7 +138,10 @@ itself.
138
138
  - The model's own configuration from Qoder's list goes with it.
139
139
  - It picks the reasoning effort from the model's own levels:
140
140
  - The nearest level to the one asked, the higher one on a tie.
141
- - The model's default when none is asked.
141
+ - The model's default when none is asked, unless the request's
142
+ `max_tokens` is 1024 or less: that is asked as "none" (since 0.2.55,
143
+ plugins#643), since thinking would spend so small a budget on
144
+ reasoning alone.
142
145
  - The lowest level for "none", when the model can't turn thinking off.
143
146
  - It picks the context window (`context_length`) from the model's own
144
147
  windows (Qoder's Context setting: 200K, 400K, 1M): the default while the
package/index.mjs CHANGED
@@ -898,12 +898,24 @@ function fitEffort(want, levels) {
898
898
  return best
899
899
  }
900
900
 
901
+ // SMALL_BUDGET is the largest max_tokens a request can name and still be
902
+ // one no client meant to think in: Anthropic's API takes thinking only with
903
+ // a budget of at least 1024 tokens and a max_tokens above it, and a client's
904
+ // own short asks (a session title, a classification) name such budgets.
905
+ // Thinking by default spends them on reasoning: on WorkBuddy, a title asked
906
+ // at 64 tokens ended "length" with 64 reasoning tokens and no text
907
+ // (plugins#643, itspig).
908
+ const SMALL_BUDGET = 1024
909
+
901
910
  // effortFor is whether to think and at which of the model's efforts ("" for
902
911
  // none): asked for none, a model that always thinks thinks at its lowest;
903
- // asked for nothing, or a level Qoder doesn't name, at its own default.
904
- function effortFor(asked, m) {
912
+ // asked for nothing, or a level Qoder doesn't name, at its own default —
913
+ // unless the request's own budget (max_tokens, 0 when it named none) is
914
+ // SMALL_BUDGET or less, which is asked as none.
915
+ function effortFor(asked, m, budget = 0) {
905
916
  let want = String(asked ?? "").toLowerCase()
906
917
  if (!EFFORT_RANK.includes(want)) want = ""
918
+ if (want === "" && budget > 0 && budget <= SMALL_BUDGET) want = "none"
907
919
  if (!m.thinks || (want === "none" && !m.alwaysThinks)) return [false, ""]
908
920
  if (!m.efforts.length) return [true, ""]
909
921
  if (want === "") return [true, m.defaultEffort]
@@ -1268,7 +1280,8 @@ function qoderBody(chat, m, named = "", task, site) {
1268
1280
  let sysText = system ? baseSystem + "\n\n" + system : baseSystem
1269
1281
  if (chat.tool_choice === "required" && tools.length) sysText += "\nYou must call an available function in this response."
1270
1282
  const sys = { type: "text", text: sysText }
1271
- const [thinking, effort] = effortFor(chat.reasoning_effort, m)
1283
+ const budget = chat.max_completion_tokens || chat.max_tokens || 0
1284
+ const [thinking, effort] = effortFor(chat.reasoning_effort, m, typeof budget === "number" ? budget : 0)
1272
1285
  const params = { enable_thinking: thinking, max_tokens: chat.max_completion_tokens || chat.max_tokens || 32000 }
1273
1286
  if (effort) params.reasoning_effort = effort
1274
1287
  const window = windowFor(chat, m, params.max_tokens)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magpie-community/opencode-qoder-auth",
3
- "version": "0.2.54",
3
+ "version": "0.2.55",
4
4
  "description": "Qoder and QwenWork (千问办公) subscriptions in OpenCode and magpie: qoder.com, qoder.cn, gateway.qwenwork.cn and the enterprise flagship, VPC and dedicated domains",
5
5
  "type": "module",
6
6
  "main": "./index.mjs",