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 <bluesmilery@users.noreply.github.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user