🔍 fix: Anthropic Web Search Multi-Turn Issue and Attachment Results#12651
Conversation
- 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.
There was a problem hiding this comment.
Pull request overview
Improves the WebSearch tool status UI so searches are treated as complete when result attachments are present (especially for server tool calls that don’t emit a completion step), making cancellation/completion state handling more accurate.
Changes:
- Adds
hasResultsandeffectiveProgressto derive completion state from attachments when progress does not advance. - Updates cancellation/completion/finalizing state checks to use
effectiveProgress.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 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, |
There was a problem hiding this comment.
This change introduces new completion/cancellation behavior via effectiveProgress for server tool calls that never report run-step completion. Please add a unit test covering the intended scenario (progress remains at default 0.1, attachments include web_search results) to ensure the component is not treated as cancelled and reaches the correct completed/finalizing state.
| () => | ||
| attachments?.some((att) => att.type === Tools.web_search && att[Tools.web_search]) ?? false, | ||
| [attachments], | ||
| ); | ||
| const effectiveProgress = hasResults ? 1 : progress; |
There was a problem hiding this comment.
hasResults currently becomes true for any web_search attachment with a truthy payload, even when it contains no actual results (e.g., { organic: [], topStories: [] } or just metadata). That can force effectiveProgress to 1 prematurely and flip the component into complete/finalizing states while the search is still in-flight. Consider computing this based on the presence of actual result items (e.g., non-empty organic/topStories, or a derived sourceCount > 0) rather than just the attachment object existing.
GitNexus: 🚀 deployedThe |
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.
…k and package.json files
GitNexus: 🚀 deployedThe |
…anny-avila#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
…anny-avila#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
effectiveProgressto reflect the actual state of progress based on the presence of results, enhancing the accuracy of cancellation and completion states.