dsh-tavily-resilient-search: A Resilient Tavily Web Search Plugin for DSH

Preface

In the DeepSeek Harness (DSH) ecosystem, web access capabilities are typically implemented through plugins. When using the Tavily API, developers frequently encounter issues with key rate limiting (429), quota exhaustion (432/433), or key revocation (401). If not handled properly, these errors can directly interrupt the Agent loop, causing task failure. dsh-tavily-resilient-search aims to address this pain point by ensuring the continuity of the Agent loop through atomic key rotation and Keyless fallback mode.

What is This

dsh-tavily-resilient-search is a standalone Cordis plugin maintained by user frederico-kluser. It provides real-time web search via the Tavily API, with core capabilities including:

  • Atomic Key Rotation: When a key in a pool encounters rate limiting or errors, automatically switches to the next available key without interrupting the Agent loop.
  • Keyless Fallback: When all keys are invalid or unconfigured, automatically switches to Keyless mode (with stricter limits) and provides a clear notification.
  • Key Management Panel: Provides a Web interface for creating, reading, updating, and deleting keys, as well as testing functionality.
  • Security Audit: Logs critical operations and rejected requests.

This plugin is licensed under the MIT License.

Installation and Activation

Installing this plugin requires Node.js version 24 or higher. The installation is performed through DSH’s package manager. The plugin declares dsh.bundle.patch, so it will be automatically activated upon installation.

dsh plugin --profile web add dsh-tavily-resilient-search

After installation, relevant configurations will be automatically injected into the DSH Bundle layer.

Configuration and Key Management

Environment Variable Configuration

Keys must be set via environment variables and must never be hardcoded in plaintext in configuration files. The plugin reads environment variables in order.

export TAVILY_API_KEY_A="tvly-..."
export TAVILY_API_KEY_B="tvly-..."
export TAVILY_API_KEY_C="tvly-..."

Web Interface Management

The plugin provides a management panel for maintaining the key pool.

  1. Accessing the Panel: In the DSH interface’s “Settings”, the “Tavily Keys” entry is displayed only when no valid keys are present.
  2. CRUD Operations: Supports adding, listing, editing, deleting, and testing keys. Edit and delete operations require secondary confirmation (nonce).
  3. Admin Token: On first launch, the system generates a CSPRNG token saved to ~/.dsh/dsh-tavily-resilient-search/admin-token.txt (permissions 0600).
    • If the token is forgotten, it can be reset via the environment variable DSH_TAVILY_ADMIN_RESET=1.
    • You can also directly set DSH_TAVILY_ADMIN_TOKEN.
  4. Security Policy: By default, only Loopback access is allowed. If binding to a public address (0.0.0.0) is required, you must explicitly enable admin.allowPublicBind: true in the configuration, otherwise the panel will refuse to start.

Configuration Parameters

Configuration is applied through Profile, Home, or CLI override layers. Note that the plugin adopts a whole-entry replacement strategy, not a deep merge.

Field Type Default Description
apiKeys string[] [] Array of keys, polled sequentially. An empty array indicates Keyless mode.
searchDepth ultra-fast\|fast\|basic\|advanced basic Search depth.
maxResults 1..100 5 Maximum number of results, automatically clamped to 10.
includeAnswer boolean true Whether to include Tavily’s summary answer.
timeoutMs number 15000 Timeout for a single HTTP request.
callTimeoutMs number 120000 Total timeout for the entire call (including rotation).
projectId string — ID for project isolation.
admin.enabled boolean true Whether to enable the management panel.
admin.trustedRemotes string[] loopback Trusted remote sources.
admin.allowedHosts string[] 127.0.0.1, localhost, ::1 Allowed Host names.
securityProfile {sandbox, approval} Required Security policy, typically sandbox: 'workspace-write', approval: 'ask'.

Tool Usage

After installation and activation, the plugin exposes the web_search tool.

Invocation:

web_search(query, search_depth, max_results, topic)

Parameters:

  • query (string, required): Search terms, recommended to be under 1500 characters, hard limit of 4000 characters.
  • search_depth (enum, optional): ultra-fast, fast, basic, advanced.
  • max_results (integer, optional): 1 to 10.
  • topic (enum, optional): general or news.

Return Value:

Returns structured data containing ok, query, answer, sources, responseTime, keylessFallbackUsed, error, detail, suggestion. Even on errors, structured information is returned instead of throwing exceptions that interrupt the process.

Error Handling Mechanism

The plugin has clear handling logic for different HTTP status codes:

  • 429 (Rate Limit) / 432 (Quota) / 433 (Quota): Marks the current key as unavailable and immediately retries with the next key, keeping the payload unchanged.
  • 401 (Unauthorized/Revoked): Key is invalid, removed from the pool and retried.
  • 400 (Bad Request): Does not rotate keys, returns error directly with correction suggestions.
  • Timeout or Network Error: Tries rotating keys; if all keys fail, triggers Keyless mode or returns an error.

Notes

  1. Node Version: Must use Node.js 24 or higher.
  2. Permissions: The plugin runs with the permissions of the current DSH process; ensure environment variables are properly set.
  3. Source Code Review: Although the license is MIT, it is recommended to review the source code before using in production to ensure compliance with security standards.
  4. Configuration Method: Configuration directly overrides configuration items; be careful not to attempt deep merges when overriding array fields like apiKeys.

Summary

dsh-tavily-resilient-search is a DSH plugin designed for high availability. Through automated key management and fault tolerance mechanisms, it solves common rate limiting and quota issues with the Tavily API in real-world usage, ensuring that Agents do not unexpectedly terminate due to API errors during web-connected tasks.

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

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

Xiaoye