From 0f73414d3bab06ce76cd17abbe4d4a82ca819fac Mon Sep 17 00:00:00 2001 From: jiwangyihao Date: Tue, 12 May 2026 19:24:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(coding-agent):=20=E8=AF=86=E5=88=AB?= =?UTF-8?q?=E9=A1=B6=E5=B1=82=E5=B7=A5=E5=85=B7=E9=94=99=E8=AF=AF=E6=A0=87?= =?UTF-8?q?=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coding-agent/src/eval/js/tool-bridge.ts | 3 ++ .../test/core/js-tool-bridge.test.ts | 30 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/packages/coding-agent/src/eval/js/tool-bridge.ts b/packages/coding-agent/src/eval/js/tool-bridge.ts index f77fe2ef3..205b9d383 100644 --- a/packages/coding-agent/src/eval/js/tool-bridge.ts +++ b/packages/coding-agent/src/eval/js/tool-bridge.ts @@ -20,6 +20,9 @@ type ToolValue = hasError?: boolean; }; function toolResultHasError(result: AgentToolResult): boolean { + if ((result as { isError?: unknown }).isError === true) { + return true; + } if (!(result.details && typeof result.details === "object")) { return false; } diff --git a/packages/coding-agent/test/core/js-tool-bridge.test.ts b/packages/coding-agent/test/core/js-tool-bridge.test.ts index 7dcd09d2a..db734d29e 100644 --- a/packages/coding-agent/test/core/js-tool-bridge.test.ts +++ b/packages/coding-agent/test/core/js-tool-bridge.test.ts @@ -109,6 +109,36 @@ describe("callSessionTool", () => { ]); }); + it("marks results with top-level isError", async () => { + const session = createSession([ + createTool( + "custom", + async () => + ({ + content: [{ type: "text", text: "preview mismatch" }], + isError: true, + }) as AgentToolResult, + ), + ]); + const statuses: Array> = []; + + const result = await callSessionTool("custom", {}, { session, emitStatus: event => statuses.push(event) }); + + expect(result).toEqual({ + text: "preview mismatch", + details: undefined, + hasError: true, + }); + expect(statuses).toEqual([ + expect.objectContaining({ + op: "custom", + chars: 16, + hasError: true, + error: "preview mismatch", + }), + ]); + }); + it("throws when the requested tool is not available in the session registry", async () => { const session = createSession([]);