duck-duck-go-reworked

Public

Forked from danielsig/duckduckgo

Reworked DuckDuckGo plugin.

1.1K Downloads

16 stars

11 forks

README

DuckDuckGo Reworked for LM Studio

Reliable DuckDuckGo web and image search tools for LM Studio with stronger anti-block resilience, better output consistency for LLM tool chaining, and cleaner diagnostics.

What was broken before

The previous implementation had several practical issues in real usage:

  • Web search sometimes returned only https://duckduckgo.com/ instead of actual results.
  • DDG redirect links were not decoded correctly, so target URLs were lost.
  • Internal DuckDuckGo links polluted the final output and looked like "valid" search hits.
  • Label extraction was noisy because HTML text was not normalized robustly.
  • Image search frequently failed with Forbidden or Unable to extract vqd token with no useful fallback path.
  • Image filtering was too strict (URL extension based), dropping valid CDN images without .jpg/.png suffixes.
  • Download stage could report confusing outcomes (including false-positive success patterns in older behavior).
  • Tool-output shape encouraged weak orchestration in some models (extra unnecessary calls to downstream image tools).

What is fixed in this reworked version

Web Search quality improvements

  • Uses https://html.duckduckgo.com/html/ for more stable HTML result pages.
  • Replaces fragile URL regex extraction with anchor-level parsing (<a href=...>).
  • Decodes DuckDuckGo redirect links via uddg into real destination URLs.
  • Filters out internal DuckDuckGo service/home links from results.
  • Cleans HTML labels and normalizes whitespace for readable output.

Image Search reliability improvements

  • Added resilient retry/backoff for DDG requests (vqd bootstrap and i.js endpoint).
  • Added improved request header profiles for document/json/image fetches.
  • Added in-memory cache for image query results and vqd tokens.
  • Added content-type validation (image/*) during downloads instead of extension-only acceptance.
  • Added explicit structured block diagnostics:
    • error: blocked_by_waf
    • stage: vqd | i.js
    • try_web_fallback: true

Multi-source fallback (no API keys)

When DDG image endpoint is blocked or unstable, Image Search now automatically runs a fallback chain:

  • DuckDuckGo web results (html.duckduckgo.com)
  • Extract image candidates from top pages (src, data-src, data-original, srcset, markdown image links)
  • Download and validate candidates (content-type: image/*)
  • Return renderable local markdown images

Fallback responses include source: "web_fallback" when that path was used.

Output consistency for LLM tool use

  • Image Search returns renderable markdown images in a consistent shape:
    • images
    • count
    • hint (that images are already downloaded/renderable)
  • This reduces redundant tool hops and improves assistant decision quality in multi-tool flows.

Better result reliability (general)

  • Preserves deduplication, pagination (page, pageSize), and safeSearch behavior.

Installation

Install from LM Studio Hub:

Then click Run in LM Studio.

Configuration

  • Search Results Per Page: max number of search results (0 = auto).
  • Safe Search: off, moderate, strict (auto lets assistant decide).

Usage

With the plugin enabled, the assistant can:

  • run web search (Web Search)
  • run image search (Image Search)
  • paginate results when needed

Works especially well with the Analyze Images and improved Visit Website plugin:

LLM can find images via this plugin, then analyze the content with analyze.

Changelog (reworked release)

  • Fixed homepage-only result regression.
  • Added DDG redirect target decoding.
  • Added internal-link filtering.
  • Improved title/label extraction cleanliness.
  • Added robust image fetch retries and anti-block diagnostics.
  • Added automatic web-fallback image pipeline when DDG image endpoint is blocked.
  • Added output consistency hints for better model tool orchestration.

Examples