🔍 fix: Anthropic Web Search Multi-Turn Issue and Attachment Results (#12651)

* 🔍 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
This commit is contained in:
Danny Avila 2026-04-13 15:44:41 -04:00 committed by GitHub
parent 5cc783b8e8
commit 60cee6eec7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 27 additions and 18 deletions

View file

@ -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",

View file

@ -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) {

22
package-lock.json generated
View file

@ -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",

View file

@ -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",