From 60cee6eec711ed7f9711b293afff8d2836081e9c Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 13 Apr 2026 15:44:41 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=8D=20fix:=20Anthropic=20Web=20Search?= =?UTF-8?q?=20Multi-Turn=20Issue=20and=20Attachment=20Results=20(#12651)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🔍 fix: Improve WebSearch Progress Handling Based on Attachment Results - Adjusted progress handling in the WebSearch component to treat searches as complete if attachments contain results, addressing issues with server tool calls not receiving completion signals. - Introduced `effectiveProgress` to reflect the actual state of progress based on the presence of results, enhancing the accuracy of cancellation and completion states. - Updated related logic to ensure proper handling of search completion and finalization states based on the new progress calculations. * fix: only override progress when not streaming During streaming (isSubmitting=true), use actual progress so the searching/processing/reading states display correctly. Only override to 1 after streaming completes to prevent the cancelled check from hiding the component. * chore: Update @librechat/agents and mathjs dependencies to latest versions * chore: Upgrade mathjs dependency to version 15.2.0 across package-lock and package.json files --- api/package.json | 4 ++-- .../Chat/Messages/Content/WebSearch.tsx | 15 ++++++++++--- package-lock.json | 22 +++++++++---------- packages/api/package.json | 4 ++-- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/api/package.json b/api/package.json index de58e79af4..add7637189 100644 --- a/api/package.json +++ b/api/package.json @@ -44,7 +44,7 @@ "@google/genai": "^1.19.0", "@keyv/redis": "^4.3.3", "@langchain/core": "^0.3.80", - "@librechat/agents": "^3.1.64", + "@librechat/agents": "^3.1.65", "@librechat/api": "*", "@librechat/data-schemas": "*", "@microsoft/microsoft-graph-client": "^3.0.7", @@ -82,7 +82,7 @@ "librechat-data-provider": "*", "lodash": "^4.17.23", "mammoth": "^1.11.0", - "mathjs": "^15.1.0", + "mathjs": "^15.2.0", "meilisearch": "^0.38.0", "memorystore": "^1.6.7", "mime": "^3.0.0", diff --git a/client/src/components/Chat/Messages/Content/WebSearch.tsx b/client/src/components/Chat/Messages/Content/WebSearch.tsx index 48e305a8a1..e4029193cc 100644 --- a/client/src/components/Chat/Messages/Content/WebSearch.tsx +++ b/client/src/components/Chat/Messages/Content/WebSearch.tsx @@ -92,10 +92,19 @@ export default function WebSearch({ const localize = useLocalize(); const { searchResults } = useSearchContext(); const error = typeof output === 'string' && output.toLowerCase().includes('error processing'); - const cancelled = (!isSubmitting && progress < 1) || error === true; - const complete = !isLast && progress === 1; - const finalizing = isSubmitting && isLast && progress === 1; + // Server tool calls (srvtoolu_) never receive ON_RUN_STEP_COMPLETED, so progress + // stays at the default 0.1. Treat the search as complete if attachments have results. + const hasResults = useMemo( + () => + attachments?.some((att) => att.type === Tools.web_search && att[Tools.web_search]) ?? false, + [attachments], + ); + const effectiveProgress = hasResults && !isSubmitting ? 1 : progress; + const cancelled = (!isSubmitting && effectiveProgress < 1) || error === true; + + const complete = !isLast && effectiveProgress === 1; + const finalizing = isSubmitting && isLast && effectiveProgress === 1; const ownTurn = useMemo((): string => { if (!attachments) { diff --git a/package-lock.json b/package-lock.json index 04de36277a..8b9406041e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -59,7 +59,7 @@ "@google/genai": "^1.19.0", "@keyv/redis": "^4.3.3", "@langchain/core": "^0.3.80", - "@librechat/agents": "^3.1.64", + "@librechat/agents": "^3.1.65", "@librechat/api": "*", "@librechat/data-schemas": "*", "@microsoft/microsoft-graph-client": "^3.0.7", @@ -97,7 +97,7 @@ "librechat-data-provider": "*", "lodash": "^4.17.23", "mammoth": "^1.11.0", - "mathjs": "^15.1.0", + "mathjs": "^15.2.0", "meilisearch": "^0.38.0", "memorystore": "^1.6.7", "mime": "^3.0.0", @@ -11859,9 +11859,9 @@ } }, "node_modules/@librechat/agents": { - "version": "3.1.64", - "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.1.64.tgz", - "integrity": "sha512-T3w4dTKaFM1VP5ubnOMyp/moG3lFACJnkl6+B1WfwJ4CkTw0PKqUg7IwDaI9eO6JvQukbFabR9BYtE4iCBX2kg==", + "version": "3.1.65", + "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-3.1.65.tgz", + "integrity": "sha512-XkyFmTsyQahnL5BwWuxcVa0ehqaD8TOypIeDk6pC0B8tLEn3rJSWEqNd3J6E5leI79J4DoHvZheboUoKzYdeMQ==", "license": "MIT", "dependencies": { "@anthropic-ai/sdk": "^0.73.0", @@ -11887,7 +11887,7 @@ "cheerio": "^1.0.0", "dotenv": "^16.4.7", "https-proxy-agent": "^7.0.6", - "mathjs": "^15.1.0", + "mathjs": "^15.2.0", "nanoid": "^3.3.7", "okapibm25": "^1.4.1", "openai": "5.8.2" @@ -32612,9 +32612,9 @@ } }, "node_modules/mathjs": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-15.1.0.tgz", - "integrity": "sha512-HfnAcScQm9drGryodlDqeS3WAl4gUTYGDcOtcqL/8s23MZ28Ib1i8XnYK3ZdjNuaW/L4BAp9lIp8vxAMrcuu1w==", + "version": "15.2.0", + "resolved": "https://registry.npmjs.org/mathjs/-/mathjs-15.2.0.tgz", + "integrity": "sha512-UAQzSVob9rNLdGpqcFMYmSu9dkuLYy7Lr2hBEQS5SHQdknA9VppJz3cy2KkpMzTODunad6V6cNv+5kOLsePLow==", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.26.10", @@ -44212,7 +44212,7 @@ "@google/genai": "^1.19.0", "@keyv/redis": "^4.3.3", "@langchain/core": "^0.3.80", - "@librechat/agents": "^3.1.64", + "@librechat/agents": "^3.1.65", "@librechat/data-schemas": "*", "@modelcontextprotocol/sdk": "^1.27.1", "@smithy/node-http-handler": "^4.4.5", @@ -44233,7 +44233,7 @@ "keyv-file": "^5.1.2", "librechat-data-provider": "*", "mammoth": "^1.11.0", - "mathjs": "^15.1.0", + "mathjs": "^15.2.0", "memorystore": "^1.6.7", "mongoose": "^8.12.1", "node-fetch": "2.7.0", diff --git a/packages/api/package.json b/packages/api/package.json index 6f9ad0ea7e..20cee98ce3 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -95,7 +95,7 @@ "@google/genai": "^1.19.0", "@keyv/redis": "^4.3.3", "@langchain/core": "^0.3.80", - "@librechat/agents": "^3.1.64", + "@librechat/agents": "^3.1.65", "@librechat/data-schemas": "*", "@modelcontextprotocol/sdk": "^1.27.1", "@smithy/node-http-handler": "^4.4.5", @@ -116,7 +116,7 @@ "keyv-file": "^5.1.2", "librechat-data-provider": "*", "mammoth": "^1.11.0", - "mathjs": "^15.1.0", + "mathjs": "^15.2.0", "memorystore": "^1.6.7", "mongoose": "^8.12.1", "node-fetch": "2.7.0",