From b57fc44b1f0972cfd9add8da2ac9a56ad7676254 Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Mon, 2 Feb 2026 17:11:15 +0800 Subject: [PATCH] fix: skip output schema validation when tool result isError Signed-off-by: Adrian Cole --- client/src/components/ToolResults.tsx | 2 +- .../components/__tests__/ToolsTab.test.tsx | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/client/src/components/ToolResults.tsx b/client/src/components/ToolResults.tsx index 38d1d0382..d7e4fa65d 100644 --- a/client/src/components/ToolResults.tsx +++ b/client/src/components/ToolResults.tsx @@ -115,7 +115,7 @@ const ToolResults = ({ error: "Tool has an output schema but did not return structured content", }; - } else if (structuredResult.structuredContent) { + } else if (structuredResult.structuredContent && !isError) { validationResult = validateToolOutput( selectedTool.name, structuredResult.structuredContent, diff --git a/client/src/components/__tests__/ToolsTab.test.tsx b/client/src/components/__tests__/ToolsTab.test.tsx index cb9ebf4ef..70dbf798f 100644 --- a/client/src/components/__tests__/ToolsTab.test.tsx +++ b/client/src/components/__tests__/ToolsTab.test.tsx @@ -483,6 +483,32 @@ describe("ToolsTab", () => { ).toBeInTheDocument(); }); + it("should not validate structuredContent against output schema when isError is true", () => { + const errorResult = { + content: [ + { + type: "text", + text: "Something went wrong", + }, + ], + structuredContent: { + errorCode: "NOT_FOUND", + }, + isError: true, + }; + + renderToolsTab({ + tools: [toolWithOutputSchema], + selectedTool: toolWithOutputSchema, + toolResult: errorResult, + }); + + // Should display structured content + expect(screen.getByText("Structured Content:")).toBeInTheDocument(); + // Should NOT show a validation error + expect(screen.queryByText(/Validation Error:/)).not.toBeInTheDocument(); + }); + it("should show unstructured content title when both structured and unstructured exist", () => { const resultWithBoth = { content: [{ type: "text", text: '{"temperature": 25}' }],