dsh-anysearch-fallback: Direct web_fetch fallback when AnySearch extraction fails

Introduction

When using web_fetch in DSH to fetch web pages, requests are routed through AnySearch’s /v1/extract for main content extraction. Many sites or paths directly return HTTP 422 extract_failed from the upstream, causing the entire tool call to fail and leaving the model with no page content. Common workarounds include switching URLs, writing manual curl commands, or wrapping the fetch yourself—all of which are inconsistent with the Harness goal of “single tool call, predictable results.”

The following introduces the community plugin dsh-anysearch-fallback (Maintainer: ADkun, Category: Web Tool). Without modifying the official @anysearch/anysearch-dsh, it registers its own fetch provider. It prioritizes the official AnySearch; if the upstream fails (except for cancellation), it falls back to a constrained direct fetch using a browser User-Agent, appending the upstream failure reason to the first line of the returned content. This plugin is a DSH plugin with zero runtime dependencies.

What is this

dsh-anysearch-fallback adds a fallback path for DSH’s web_fetch: When AnySearch cannot extract a page (typically HTTP 422) or encounters other upstream errors, instead of letting the entire call fail directly, it fetches the HTML directly within security boundaries, performs naive noise reduction, and returns plain text. When successful via AnySearch, the returned fields remain consistent with the original official provider.

The plugin registers with the provider id anysearch-fallback and points the web service’s fetchProvider to it via profile configuration. Internally, it calls the official anysearch provider by id without modifying DSH private fields.

Working Mechanism

Based on the positioning above, the call chain can be understood as a proxy layer:

  1. web_fetch selects the anysearch-fallback provider registered by this plugin.
  2. It proxies to the official AnySearch extract: if successful, it returns the result as-is; if cancelled/aborted, it throws the error as-is and never downgrades.
  3. Any other upstream failure (422, 401, 402, 403, 429, 5xx, timeout, network issues, non-JSON, etc.) triggers the direct fetch fallback.
  4. The direct fetch uses a fixed desktop Chrome User-Agent, combined with protocol/internal network validation, a 5 MB byte limit, and a 15s timeout. The top of the result includes a demotion marker explaining the upstream status and direct fetch status.

Upgrades or reinstalls of the official AnySearch plugin do not affect this plugin’s logic; if the official provider id changes, UPSTREAM_PROVIDER_ID in the repo’s index.mjs must be updated accordingly.

Core Behavior Summary

Item Description
Trigger Fallback Any upstream error except cancellation
No Fallback If signal is aborted, or the error is AbortError / ABORT_ERR / WEB_ABORTED / extract_canceled, etc.
Protocol Only http: / https:
Internal Network Rejects localhost, private network segments, link-local addresses, etc. (including IP verification after DNS resolution; no address pinning, see boundaries below)
Direct Fetch Limits 5 MB streaming read, 15s timeout, max 3 redirects with re-validation per hop; no Authorization / Cookie / Referer
Disk Cache None

During fallback, the first line of the body is always a marker. For example, if the upstream returns 422 and the direct fetch returns 200 with content, it will state “Upstream extraction failed” and “Direct fetch succeeded,” indicating that the following is raw text not cleaned by AnySearch. Systemic issues like upstream 401, 402, 429, etc., also go through the broad fallback: the call may still return a page, so you need to judge integration health based on the first-line marker and warn logs, not just the HTTP 200 status.

Installation and Activation

The method provided in the README is to mount it as a local plugin to a DSH profile; there is no one-line command like dsh plugin add github:.... Perform the following steps in order.

# 1) Place this directory at <DSH_HOME>/plugins/dsh-anysearch-fallback/
# 2) Add the dependency to the profile's package.json (relative path notation)
#    "dsh-anysearch-fallback": "file:C:/Users/you/.dsh/plugins/dsh-anysearch-fallback"
# 3) Append it to the end of the profile's dsh.profile.bundles
#    (Putting it last = its `- id: web` override takes effect after the official anysearch)
# 4) Create a same-named entry under the profile's node_modules (existing local shape: real directory + hard link)
# 5) Restart DSH —— Starting a new conversation is not enough; the profile's config tree is assembled at startup

The cordis.patch.yml in the repo inserts bundle dsh-anysearch-fallback and sets the web fetchProvider to anysearch-fallback; searchProvider needs to be written completely according to the current profile status (patch replaces config entirely, no deep merge). Adjust specific layer overrides according to your current profile.

Note: After modifying the plugin or profile, you must restart the DSH process; starting a new conversation will not load the new code.

Runtime environment requires Node >=22 (see engines in package.json). License is MIT.

Typical Usage and Verification

No additional configuration is needed daily: once the profile is enabled, the agent calls web_fetch as usual; downgrading only happens automatically on upstream failure, and the success path is identical to the official AnySearch.

Developers can run offline unit tests in the repo:

npm test            # Offline unit tests: 63 passed / 1 skipped (network cases skipped by default)

Network integration tests are in test/integration.test.mjs and are skipped by default; they require the local machine to resolve @anysearch/anysearch-dsh and its peers, and a temporary staging setup (including junctions to @deepseek-ai/*) according to the comments at the top of that file before running.

Applicable Scenarios and Notes

Who it is for: Teams that frequently have agents fetch open web pages and want to avoid the entire web_fetch call failing when AnySearch 422 or occasional upstream errors occur; teams that accept that direct fetch content quality is lower than AnySearch cleaning and are willing to look at the first-line marker to distinguish between “normal extraction” and “fallback results.”

Must Know:

  • The plugin runs with the current DSH process permissions. Before installation, please read the source code and MIT license to ensure the SSRF and direct fetch strategies meet your security requirements.
  • Direct fetch only performs naive HTML noise reduction; anti-scraping sites may return 403 or empty content for anonymous requests (README examples: openai.com, Zhihu question pages). The marker explains the situation, but the content may still be unusable, requiring a different source.
  • Broad fallback means credential failures, quota exhaustion, rate limiting, etc., may also manifest as “page still returned”; troubleshooting integration issues requires looking at the first-line marker and warn logs, not just HTTP 200.
  • DNS rebinding is only checked via resolution and re-verification; there is no address pinning bound to the connection. URLs with userinfo are explicitly rejected with WEB_BLOCKED_URL, not silently stripped.
  • The community directory SkillHub is maintained by the community and has no official affiliation with DeepSeek / Hiina; the DSH ecosystem philosophy is “Everything is a plugin,” and this plugin is an optional component in the web tool category.

Conclusion

dsh-anysearch-fallback provides a constrained direct fetch fallback for web_fetch when AnySearch extraction fails or upstream errors occur. It has zero runtime dependencies and does not modify the official AnySearch package. If your profile already relies on AnySearch for web fetching, you can add this plugin as an enhancement layer at the end of the bundles chain, and develop the habit of checking the fallback first line and restarting DSH.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye