diff --git a/packages/devin/README.md b/packages/devin/README.md index 569f46e..c6dc164 100644 --- a/packages/devin/README.md +++ b/packages/devin/README.md @@ -59,7 +59,8 @@ The plugin's `fetch` handles this: message after the results ("[From the result of …]"). - The Claude models are asked on Anthropic's Messages API (`@ai-sdk/anthropic`, `POST …/devin/v1/messages`); every other model - stays on chat completions (since 0.1.28, #566). + stays on chat completions (since 0.1.28, #566). A failed tool result + says so in its text, "Error: " first (0.1.29). - Each text block, system block, tool call turn and tool result is a `ChatMessagePrompt` of its own, in the order the client sent them, and one the client marked with `cache_control` carries diff --git a/packages/devin/cache-marks.test.mjs b/packages/devin/cache-marks.test.mjs index 3c5bff4..bf839e8 100644 --- a/packages/devin/cache-marks.test.mjs +++ b/packages/devin/cache-marks.test.mjs @@ -101,6 +101,24 @@ test("tool calls and results keep their own prompts and marks", () => { expect(offered).toEqual(["read_file"]) }) +test("a failed result says so in its text, as on chat completions", () => { + const ps = prompts( + buildMessages( + { + model: "claude-haiku-5-5", + messages: [ + { role: "user", content: "go" }, + { role: "assistant", content: [{ type: "tool_use", id: "c1", name: "Bash", input: {} }] }, + { role: "user", content: [{ type: "tool_result", tool_use_id: "c1", content: "exit status 1", is_error: true }] }, + ], + }, + "claude-haiku-5-5", + "k", + ), + ) + expect(ps.find((p) => p.role === 4).text).toBe("Error: exit status 1") +}) + test("a Messages request's effort is read as magpie reads it", () => { expect(anthropicEffort({ thinking: { type: "adaptive" }, output_config: { effort: "high" } })).toBe("high") expect(anthropicEffort({ thinking: { type: "enabled", budget_tokens: 10000 } })).toBe("medium") diff --git a/packages/devin/index.mjs b/packages/devin/index.mjs index d0e332e..7a4c1ec 100644 --- a/packages/devin/index.mjs +++ b/packages/devin/index.mjs @@ -1938,7 +1938,10 @@ function buildMessages(req, uid, key) { const inner = typeof b.content === "string" ? [{ type: "text", text: b.content }] : Array.isArray(b.content) ? b.content : [] const text = inner.filter((x) => x?.type === "text" && x.text).map((x) => x.text).join("\n\n") const images = inner.map(anthropicImage).filter(Boolean) - msgs.push({ role: TOOL, callID: pending[i].id, text: text || "(no output)", images, cache: marked(b) || marked(inner[inner.length - 1]) }) + // Devin has no failed mark on a result: it is said in the text, as + // magpie's gateway says it on chat completions (failedAsText) + const said = text || "(no output)" + msgs.push({ role: TOOL, callID: pending[i].id, text: b.is_error ? "Error: " + said : said, images, cache: marked(b) || marked(inner[inner.length - 1]) }) pending.splice(i, 1) continue } diff --git a/packages/devin/package.json b/packages/devin/package.json index 9fa5171..eeb9668 100644 --- a/packages/devin/package.json +++ b/packages/devin/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-devin-auth", - "version": "0.1.28", + "version": "0.1.29", "description": "Devin subscriptions (the devin CLI's account) in OpenCode and magpie", "type": "module", "main": "./index.mjs",