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}' }],