Skip to content

feat(ai): web search falls back to DuckDuckGo after Firecrawl #3876

Closed

Description

@dan-petty

Problem

The web search of the roadmap jobs has one backend: the hosted Firecrawl API (firecrawl_search in src/devops_cli/ai/common_tools.py). When Firecrawl refuses a search, the search returns nothing. On 2026-11-06 the Service logged 7 searches in 24 hours that failed with Firecrawl answered with HTTP 402 (the credit of the account is used up). The alternatives check and the refine investigation then run without web results, and the check cannot tell a missing tool from a failed search.

Expected

When a Firecrawl search fails (HTTP 402, 429, 5xx, a timeout or an empty reply that is an error), the same call searches with DuckDuckGo and returns results in the same form. A search that Firecrawl answered is not repeated. The metric devops_cli_firecrawl_searches_total keeps its meaning, and a second metric or label tells which backend answered. A fallback is logged once per search, with the reason.

Acceptance criteria

  • A test: Firecrawl answers HTTP 402, the fallback runs, and the caller gets DuckDuckGo results in the form of Firecrawl results.
  • A test: Firecrawl answers with results, and the fallback does not run.
  • A test: both backends fail, and the call returns an error result the way a Firecrawl failure does today (no exception that stops the job).
  • The metric tells the backend that answered. docs/TELEMETRY.md lists it.
  • The fallback goes through the HTTP entry point of the project and its egress rules (SECURITY.md); a query never holds private code or a secret (SECURITY.md rule 13).
  • k8s/README.md and docs/roadmap/alternatives.md name the fallback.

Existing tool considered

pydantic-ai ships a DuckDuckGo search tool that uses the maintained ddgs package. Use that, or ddgs directly if the tool does not fit the result form. No home-grown scraper of the DuckDuckGo page. SearXNG is a second option for a later item.

Related

Related: #2475 (Firecrawl metric), #2398, #2650, #3243. The investigation of a wider research agent is a separate item.

Activity

  1. added
    source/agent
    type/feature
    scope/ai
    status/new
    value/medium
    effort/medium
    on Nov 7, 2026
  2. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/feature. The feat prefix of the title gives the type.
    • Scope: scope/ai. The (ai) scope of the title gives the scope.
    • Priority: P2-Medium. Firecrawl failures degrade the alternatives check and refine investigation, but the system still runs; it is a reliability gap, not an outage.
    • Value: Medium. Users get web results when Firecrawl is down, which keeps the roadmap pipeline functional.
    • Effort: Medium. Requires DuckDuckGo integration, metrics, logging, three tests, and documentation updates across multiple files.
    • Related: chore(ai): Audit devops-cli web features for Firecrawl adoption #2432, which asks for a different change. Both concern Firecrawl web search in devops-cli, but #2432 audits which features should adopt Firecrawl while the candidate adds a DuckDuckGo fallback for when Firecrawl fails.
  3. added
    priority/p2-medium
    owner/agent
    on Nov 7, 2026
  4. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Answer from project standards, under the owner's instruction of 2026-11-05.

    Question: can the fallback use the pydantic-ai DuckDuckGo tool or ddgs, and can it go through the project HTTP entry point?

    Answer: use ddgs 9.16.1 (MIT, published 2026-10-23, maintained), but not through its client. The pydantic-ai tool only wraps DDGS().text. DDGS sends its requests with primp, which takes no transport, so a request would skip the egress check of devops_cli.http.client (SECURITY.md rule 2). The Duckduckgo engine of ddgs splits the work into build_payload, a request and extract_results. The change calls those parts and sends the request with http_client(level=EgressLevel.PUBLIC). It writes no scraper. primp 2.0.1 and lxml 6.1.3 have cp314 manylinux wheels, so the python:3.14-slim-trixie stage installs them with uv sync --locked.

    Egress: devops-default-perimeter admits public TCP 443, so html.duckduckgo.com needs no new rule.

    Rule and code that give the answer: AGENTS.md rules 2 and 3, SECURITY.md rule 2, ddgs/engines/duckduckgo.py in ddgs 9.16.1.

    Metric: a new counter devops_cli_web_search_fallbacks_total (backend, result) tells the backend. devops_cli_firecrawl_searches_total keeps its meaning, because the alerts read it.

    A person must decide one point, not blocking this item: a search with no Firecrawl key. The jobs turn the web search off with no key. A fallback-only mode would need a decision on that rule. This item does not change it.

  5. added
    status/in-progress
    and removed
    status/new
    on Nov 7, 2026
  6. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Plan note of 2026-11-07, from the owner's request to add a local SearXNG and the Brave Search API.

    PR #3900 stays as it is. Merge it when its checks pass. It adds the function web_search (Firecrawl, then DuckDuckGo), the function duckduckgo_search, and the counter devops_cli_web_search_fallbacks_total.

    A later item (feat(ai): search the web through a chain of providers) will replace web_search with one search over a list of providers: searxng, brave, duckduckgo, firecrawl. It will move duckduckgo_search into the duckduckgo provider, with its tests and the ddgs dependency. It will replace the two counters by devops_cli_web_searches_total{backend,result}. That item starts after this pull request merges. No code stacks on branch feat/3876-ddg-search-fallback.

    The point for a person in the comment of 2026-11-07 (a search with no Firecrawl key) moves to that item: the chain turns web search on for a public repository when any provider is configured, and DuckDuckGo needs no key.

  7. dan-petty commented on Nov 7, 2026

    @dan-petty
    OwnerAuthor

    Plan note of 2026-11-07 (owner decision): the Brave Search API is not used. Its terms (1 Sep 2026) forbid storing results and it has no free tier. This replaces the part of the earlier plan note that mentions Brave:

    • The search chain is searxng, duckduckgo, firecrawl. There is no keyed provider for now, and no BRAVE_SEARCH_API_KEY.
    • The keep parameter and the allows_keep flag are dropped from the design of the chain (they existed only because of the Brave terms). Every provider's hits may be kept.
    • What goes into the research index does not change: fetched page text, with the URL of the page taken from the fetch. The payload still holds no field of a search result (title, snippet, rank, age), because the index stores pages, not search results.
    • The measures of docs(ai): investigate a web research agent with RAG ingestion #3877 and feat(research): ask mode reads the index before the web #3915 may use any provider of the chain.
  8. added
    status/in-review
    and removed
    status/in-progress
    on Nov 7, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 7, 2026
  10. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 05:06 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/aisource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions