Skip to content

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

Merged
danny-avila merged 4 commits into
devfrom
fix/anthropic-web-search
Apr 13, 2026
Merged

🔍 fix: Anthropic Web Search Multi-Turn Issue and Attachment Results#12651
danny-avila merged 4 commits into
devfrom
fix/anthropic-web-search

Conversation

@danny-avila

Copy link
Copy Markdown
Owner
  • 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.

- 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.
Copilot AI review requested due to automatic review settings April 13, 2026 19:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 hasResults and effectiveProgress to 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.

Comment on lines +96 to +100
// 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,

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +103
() =>
attachments?.some((att) => att.type === Tools.web_search && att[Tools.web_search]) ?? false,
[attachments],
);
const effectiveProgress = hasResults ? 1 : progress;

Copilot AI Apr 13, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@danny-avila danny-avila changed the title 🔍 fix: Improve WebSearch Progress Handling Based on Attachment Results 🔍 fix: Anthropic WebSearch Progress Handling Based on Attachment Results Apr 13, 2026
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-12651 index is now live on the MCP server.
Deploy run

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.
@danny-avila danny-avila changed the title 🔍 fix: Anthropic WebSearch Progress Handling Based on Attachment Results 🔍 fix: Anthropic Web Search Multi-Turn Issue and Attachment Results Apr 13, 2026
@danny-avila
danny-avila merged commit 60cee6e into dev Apr 13, 2026
15 checks passed
@danny-avila
danny-avila deleted the fix/anthropic-web-search branch April 13, 2026 19:44
@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-12651 index is now live on the MCP server.
Deploy run

jcbartle pushed a commit to jcbartle/LibreChat that referenced this pull request May 11, 2026
…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
ThomasVuNguyen pushed a commit to ThomasVuNguyen/LibreChat that referenced this pull request Jul 15, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants