From 2f8f061a2c65d42225e6bf3a164924b3a7421be6 Mon Sep 17 00:00:00 2001 From: bluesmilery Date: Sun, 15 Nov 2026 22:01:28 +0800 Subject: [PATCH] devin 0.1.43: adjacent signed thoughts replay without an empty prompt (#1183) After a gateway web search, one Claude assistant turn can hold two adjacent signed thinking blocks before the answer. On replay the first went out as an assistant prompt with no text and no call, and Devin answered the next request 400 (yetone/magpie#6742). The last block of each adjacent run now goes on the prompt that follows, with its own text and signature; the earlier ones are dropped, as the API drops earlier thinking anyway. Reviewed at 163f08fe0, merged onto main 0262214e6, on macOS (mote) with a temp HOME: bun test packages/devin, 221 pass, 0 fail; bun scripts/check.mjs devin passes. Broken by hand: with main's index.mjs the new test fails. The author reports a live replay going from 400 to 200; not tried here against a real Devin account. Co-authored-by: bluesmilery --- packages/devin/index.mjs | 7 +++++-- packages/devin/package.json | 2 +- packages/devin/thinking-signature.test.mjs | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/devin/index.mjs b/packages/devin/index.mjs index 731d3b5..ae76eff 100644 --- a/packages/devin/index.mjs +++ b/packages/devin/index.mjs @@ -2065,7 +2065,7 @@ function buildMessages(req, uid, key) { if (thought) [p.thinking, thought] = [thought, null] return p } - for (const b of t.blocks) { + for (const [i, b] of t.blocks.entries()) { if (b?.type === "text" && typeof b.text === "string") { if (b.text) own.push(take({ role: ASSISTANT, text: b.text, calls: [], cache: marked(b) })) else if (marked(b) && own.length) own[own.length - 1].cache = true @@ -2073,7 +2073,10 @@ function buildMessages(req, uid, key) { calls.push({ id: inID(b.id), name: b.name, args: JSON.stringify(b.input ?? {}) }) mark ||= marked(b) } else if (b?.type === "thinking" && claude && typeof b.signature === "string" && b.signature) { - // two in a row: the first has a prompt of its own + // Devin rejects a signed thought on an otherwise empty assistant prompt. + // A gateway search can leave adjacent thoughts; keep the last one intact. + const next = t.blocks[i + 1] + if (next?.type === "thinking" && typeof next.signature === "string" && next.signature) continue if (thought) own.push(take({ role: ASSISTANT, text: "", calls: [] })) thought = { text: typeof b.thinking === "string" ? b.thinking : "", signature: b.signature, type: sigTypeOf(b.signature) } } else if (b?.type === "thinking" && !claude && typeof b.thinking === "string" && b.thinking) { diff --git a/packages/devin/package.json b/packages/devin/package.json index d70cfff..801c21e 100644 --- a/packages/devin/package.json +++ b/packages/devin/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-devin-auth", - "version": "0.1.42", + "version": "0.1.43", "description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie", "type": "module", "main": "./index.mjs", diff --git a/packages/devin/thinking-signature.test.mjs b/packages/devin/thinking-signature.test.mjs index 2a80fc6..67541ec 100644 --- a/packages/devin/thinking-signature.test.mjs +++ b/packages/devin/thinking-signature.test.mjs @@ -134,6 +134,20 @@ test("the next request sends Claude's signed thinking back on the prompt that fo expect(only).toEqual({ role: 2, text: "", calls: ["read_file"], thinking: "t", signature: SIG, type: "anthropic" }) }) +test("a search turn with adjacent signed thoughts replays without a thinking-only assistant prompt", () => { + const messages = [ + { role: "user", content: "Look it up." }, + { role: "assistant", content: [ + { type: "thinking", thinking: "Search first.", signature: "s1" }, + { type: "thinking", thinking: "Use the result.", signature: "s2" }, + { type: "text", text: "Found it." }, + ] }, + { role: "user", content: "Continue." }, + ] + const ps = prompts(buildMessages({ messages }, "claude-opus-5-5", "k")).filter((p) => p.role === 2) + expect(ps).toEqual([{ role: 2, text: "Found it.", calls: [], thinking: "Use the result.", signature: "s2", type: "anthropic" }]) +}) + test("thinking after the text goes on a prompt of its own ahead of the calls", () => { const ps = prompts( buildMessages(