From 3d56e7e4d6e6e6ed270dc365e839bf11d7d8118f Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 31 Oct 2026 10:32:35 +0800 Subject: [PATCH] kiro 0.1.23: an effort without thinking asked for is sent no thinking (#538) thinking() turned thinking on for any output_config.effort above low, even when the request had no thinking object or had thinking disabled. Claude Code's title and side requests carry an effort and no thinking, and a turn with thinking turned off says disabled, so Kiro was sent a budget for them, or, for a model whose catalog lists effort fields, adaptive thinking at that level. Low alone was spared. Now only thinking.type enabled or adaptive asks for thinking, as Anthropic's API and magpie's gateway (anthropic.go) read a request. With thinking on, nothing changes: each of low, medium, high, xhigh and max goes as additionalModelRequestFields {thinking: adaptive, output_config: {effort}} when the model's schema lists it, else as the 10k/20k/30k/50k/50k budget. Run: HOME=$(mktemp -d) bun test in packages/kiro on mote: 118 pass. bun scripts/check.mjs: ok. Broken by hand: with index.mjs at HEAD~, the new "an effort without thinking asked for" test fails, the per-level test passes. A probe built the body for every level x {adaptive, enabled, none, disabled} x {schema, no schema}. Not tried: a live Kiro account whose catalog lists effort levels. --- packages/kiro/README.md | 4 ++++ packages/kiro/effort.test.mjs | 38 ++++++++++++++++++++++++++++++++++- packages/kiro/index.mjs | 9 +++++++-- packages/kiro/package.json | 2 +- 4 files changed, 49 insertions(+), 4 deletions(-) diff --git a/packages/kiro/README.md b/packages/kiro/README.md index b64bf92..e1c644c 100644 --- a/packages/kiro/README.md +++ b/packages/kiro/README.md @@ -145,6 +145,10 @@ request: IDE sends it: `additionalModelRequestFields` with `thinking.type: "adaptive"` and `output_config.effort` (or `reasoning.effort`), and no budget. So xhigh and max stay apart there (#538). + Thinking is asked for only when the request's `thinking` is `enabled` or + `adaptive`. An effort with no `thinking`, or with it `disabled` (Claude + Code's title requests, or a turn with thinking off), is sent with no + thinking at any level. - Anthropic's hosted web search is answered with Kiro's own web search (see [Web search](#web-search)). - Kiro's failures keep their meaning: diff --git a/packages/kiro/effort.test.mjs b/packages/kiro/effort.test.mjs index ceea5bd..888dd0b 100644 --- a/packages/kiro/effort.test.mjs +++ b/packages/kiro/effort.test.mjs @@ -9,7 +9,7 @@ test("a thinking model offers xhigh as its own level", () => { expect(Object.keys(got.variants)).toEqual(["low", "medium", "high", "xhigh", "max"]) expect(got.variants.xhigh).toEqual({ thinking: { type: "enabled", budgetTokens: 50000 } }) } - expect(_internal.thinking({ output_config: { effort: "xhigh" } }, "claude-opus-5.5")).toBe(50000) + expect(_internal.thinking({ thinking: { type: "adaptive" }, output_config: { effort: "xhigh" } }, "claude-opus-5.5")).toBe(50000) // a model that doesn't think offers none expect(_internal.configModel({ id: "deepseek-3.2", name: "DeepSeek" }).variants).toBeUndefined() }) @@ -93,3 +93,39 @@ test("a model Kiro lists without effort fields keeps its budget", async () => { await listed([model("claude-opus-5.5", { properties: { thinking: OPUS_SCHEMA.properties.thinking, reasoning: OPUS_SCHEMA.properties.output_config } })]) expect(repro("claude-opus-5.5", "max").additionalModelRequestFields).toEqual({ thinking: { type: "adaptive" }, reasoning: { effort: "max" } }) }) + +// #538 (zengxiaosong): thinking is asked for by the thinking object alone. +// An effort with no thinking (Claude Code's title requests, or its turn with +// thinking off), or with thinking disabled, was sent a budget, or adaptive +// thinking at that level, for every effort above low. +test("an effort without thinking asked for is sent no thinking, at every level", async () => { + for (const schema of [OPUS_SCHEMA, null]) { + await listed([model("claude-opus-5.5", schema)]) + for (const effort of ["low", "medium", "high", "xhigh", "max"]) + for (const th of [undefined, { type: "disabled" }, { type: "between_tools" }]) { + const req = { ...(th ? { thinking: th } : {}), output_config: { effort }, messages: [{ role: "user", content: "q" }] } + expect(_internal.thinking(req, "claude-opus-5.5")).toBe(0) + const body = JSON.parse(_internal.buildKiro(req, "claude-opus-5.5", "", _internal.thinking(req, "claude-opus-5.5"))) + expect(body.additionalModelRequestFields).toBeUndefined() + expect(said(body)).not.toContain("thinking_mode") + } + } +}) + +// with thinking asked for, every level, low included, reaches Kiro as itself +// when the model lists it, and as the budget otherwise +test("each level with thinking on is the field Kiro lists, or its budget", async () => { + const budgets = { low: 10000, medium: 20000, high: 30000, xhigh: 50000, max: 50000 } + for (const th of [{ type: "adaptive" }, { type: "enabled", budget_tokens: 12345 }]) + for (const [effort, b] of Object.entries(budgets)) { + const req = { thinking: th, output_config: { effort }, messages: [{ role: "user", content: "q" }] } + await listed([model("claude-opus-5.5", OPUS_SCHEMA)]) + let body = JSON.parse(_internal.buildKiro(req, "claude-opus-5.5", "", _internal.thinking(req, "claude-opus-5.5"))) + expect(body.additionalModelRequestFields).toEqual({ thinking: { type: "adaptive" }, output_config: { effort } }) + expect(said(body)).not.toContain("max_thinking_length") + await listed([model("claude-opus-5.5", null)]) + body = JSON.parse(_internal.buildKiro(req, "claude-opus-5.5", "", _internal.thinking(req, "claude-opus-5.5"))) + expect(body.additionalModelRequestFields).toBeUndefined() + expect(said(body)).toContain(`enabled${b}`) + } +}) diff --git a/packages/kiro/index.mjs b/packages/kiro/index.mjs index f495855..6e8303c 100644 --- a/packages/kiro/index.mjs +++ b/packages/kiro/index.mjs @@ -842,10 +842,15 @@ function documentText(p) { } // thinking is whether the model is asked to think aloud, and for how -// long: when the caller asked for it, of a Claude model (or Auto). +// long: when the caller asked for it, of a Claude model (or Auto). Only a +// thinking of type enabled or adaptive asks for it, as Anthropic's API +// reads a request: an effort with no thinking (Claude Code's title and +// other side requests, or its main turn with thinking turned off), or with +// thinking disabled, is sent no thinking at any level (#538), as magpie's +// gateway reads it too. function thinking(req, model) { const effort = req.output_config?.effort ?? "" - const on = req.thinking?.type === "enabled" || req.thinking?.type === "adaptive" || (effort && effort !== "low") + const on = req.thinking?.type === "enabled" || req.thinking?.type === "adaptive" if (!on || !thinks(String(model).toLowerCase())) return 0 const budget = { low: 10000, high: 30000, xhigh: 50000, max: 50000 }[effort] if (budget) return budget diff --git a/packages/kiro/package.json b/packages/kiro/package.json index 793ec83..df42a1c 100644 --- a/packages/kiro/package.json +++ b/packages/kiro/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-kiro-auth", - "version": "0.1.22", + "version": "0.1.23", "description": "Kiro subscriptions (Free, Pro, Pro+, Power) in OpenCode and magpie", "type": "module", "main": "./index.mjs",