langchain-ai / langchain-ai/deepagents
Support arbitrary/pluggable web search providers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 29.6k
- Forks
- 4.1k
- Avg merge
- 22h 17m
- Merged PRs (30d)
- 485
Description
Drafted on behalf of a community request from the Deep Agents Slack: a user running dcode (
deepagents-code) at home wants to point web search at their own self-hosted SearXNG instance instead of being required to use Tavily.
Feature description
Today the web_search tool in dcode is hardwired to Tavily. The implementation in libs/code/deepagents_code/tools.py constructs a TavilyClient directly (_get_tavily_client), gates availability on settings.has_tavily / TAVILY_API_KEY, and calls client.search(...) with Tavily-specific arguments. There is no supported way to swap in a different search backend.
This is a problem for:
- Self-hosting / privacy-conscious users who run their own metasearch engine (e.g. SearXNG) and don't want queries leaving their network or going to a third-party SaaS.
- Air-gapped / on-prem deployments where Tavily is unreachable or disallowed.
- Cost / quota — users who already pay for or self-host an alternative shouldn't need a separate Tavily key.
We'd like dcode's web search to support arbitrary / pluggable search providers, with Tavily remaining the default so nothing changes for existing users.
Proposed solution (optional)
A few directions, roughly in order of effort, for maintainers to weigh in on:
- Provider selection via config/env. Introduce something like
SEARCH_PROVIDER(defaulttavily) plus provider-specific settings (e.g.SEARXNG_BASE_URL).web_searchwould dispatch to the configured backend while keeping its current input/return shape stable. - Built-in SearXNG provider. Ship a SearXNG implementation that hits a configurable instance's
/search?format=jsonendpoint and maps results into the existing{results: [{title, url, content, score}], query}shape that the tool/prompts already expect. - Custom-callable hook. Allow users to register their own
web_searchcallable (or a LangChain search tool) so any backend can be plugged in without dcode shipping a built-in for it.
Notes / constraints worth preserving:
- Keep the existing
web_searchsignature and return/error dict shape stable —deepagents-talonimportsweb_searchandfetch_urldirectly (see the maintainer note intools.py). - The existing SSRF guards (
_validate_url/ pinned-DNS) matter here: pointing search at a user-supplied base URL (LAN SearXNG) needs care so the guard doesn't block legitimate private instances while still protecting the agent-drivenfetch_urlpath. Worth deciding whether self-hosted-search base URLs are explicitly trusted/allowlisted.
Additional context (optional)
- Current Tavily wiring:
libs/code/deepagents_code/tools.py(web_search,_get_tavily_client) andlibs/code/deepagents_code/config.py(tavily_api_key,has_tavily,TAVILY_API_KEY). - SearXNG JSON output format: https://docs.searxng.org/dev/search_api.html
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in libs/code/deepagents_code/tools.py with web_search and _get_tavily_client, then inspect libs/code/deepagents_code/config.py for the existing Tavily settings and availability checks. Review the SearXNG search API format and determine the provider boundary, configuration, and trust handling. Done means an alternative provider can be selected while the existing web_search signature and return/error shape remain stable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100