Skip to content

fix(websearch): preserve searxng results when fetch fails#13611

Open
156554395 wants to merge 3 commits intoCherryHQ:mainfrom
156554395:fix/12954-searxng-fallback-results
Open

fix(websearch): preserve searxng results when fetch fails#13611
156554395 wants to merge 3 commits intoCherryHQ:mainfrom
156554395:fix/12954-searxng-fallback-results

Conversation

@156554395
Copy link

Summary

  • preserve SearXNG search results when page content fetching fails
  • fall back to the original SearXNG snippet instead of dropping the result
  • add tests covering fetch failure and no-content fallback behavior

Problem

Fixes #12954.

SearXNG may return relevant search results, but Cherry Studio currently fetches each result page and drops items when readable content extraction fails. In practice, this can make the LLM receive a smaller, distorted, or seemingly fixed set of results even though SearXNG itself returned useful matches.

Fix

When fetchWebContent() fails or returns No content found, keep the original SearXNG result by falling back to its existing title/content/url fields.

This keeps successful page extraction behavior unchanged, while avoiding loss of relevant search results when downstream fetching fails.

Testing

  • added unit tests for fallback when page fetching returns No content found
  • added unit tests for fallback when page fetching throws
  • added unit tests to confirm fetched page content is still preferred when available
  • ran:
    • node node_modules/vitest/vitest.mjs run src/renderer/src/providers/WebSearchProvider/SearxngProvider.test.ts

Copy link
Collaborator

@GeorgeDong32 GeorgeDong32 left a comment

Choose a reason for hiding this comment

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

感谢您的贡献!

首先,非常感谢您为 Cherry Studio 提交这个修复!这是一个高质量的初次贡献,我们非常欢迎新贡献者加入社区。🎉


问题修复评估

您对 fix(websearch): preserve searxng results when fetch fails 的修复完全解决了 Issue #12954 的根本问题:

根本原因: 原始代码在 fetchWebContent 失败或返回 noContent 时,直接丢弃整个搜索结果项,导致 LLM 只能收到部分"恰好能抓取成功"的结果,呈现出"固定且不相关"的现象。

您的修复方案:

  • ✅ 正确实现了 fallback 机制,保留 SearXNG 原始数据
  • ✅ 添加了超时控制防止页面抓取无限期挂起
  • ✅ 测试覆盖了核心场景

需要修改的问题

⚠️ 此 PR 包含了多个不相关的变更

我们发现此 PR 混合了以下几个独立的功能/修复:

Commit 内容 建议
feat: Add configurable web-search timeout setting Web 搜索超时配置 UI 应拆分为独立 PR
fix(agent): allow clearing accessible directories Agent 目录清理修复 应拆分为独立 PR
fix(websearch): preserve searxng results when fetch fails SearXNG fallback 修复 本 PR 应只保留此项

请将不相关的 commits 拆分到独立的 PR 中,这样可以:

  • 更容易进行 code review
  • 独立追踪每个功能/修复的变更
  • 降低合并风险

测试相关说明

Windows 平台上的 BaseService.resolveAccessiblePaths 测试失败可以忽略(那是其他变更引入的),我们只需要关注您 SearXNG 修改部分的测试即可。您的测试用例覆盖了核心场景,很好!


总结

感谢您的耐心和贡献!请将不相关的变更拆分后,我们可以尽快合并 SearXNG fallback 修复的部分。如果有任何问题,欢迎在评论中讨论。

@156554395 156554395 force-pushed the fix/12954-searxng-fallback-results branch from 35ef1fd to 3cafa7d Compare March 19, 2026 08:02
@156554395
Copy link
Author

Thanks for the review! I have updated this PR to keep only the SearXNG fallback fix and its related websearch-only adjustments.\n\nChanges made:\n- removed the unrelated timeout settings UI changes\n- removed the unrelated agent accessible-directories changes\n- kept only the SearXNG fallback fix and its focused tests\n\nI also re-ran the SearXNG renderer tests and verified the modified files pass Biome formatting locally.\n\nPlease take another look when convenient. Thanks!

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.

[Discussion]: When using SearXNG, the content received by the LLM is incorrect and fixed

2 participants