Skip to content

fix(web_tools): delegate backend availability to provider registry is_available()#28652

Open
m0n5t3r wants to merge 3 commits into
NousResearch:mainfrom
m0n5t3r:refactor/web-backend-is-available
Open

fix(web_tools): delegate backend availability to provider registry is_available()#28652
m0n5t3r wants to merge 3 commits into
NousResearch:mainfrom
m0n5t3r:refactor/web-backend-is-available

Conversation

@m0n5t3r

@m0n5t3r m0n5t3r commented May 19, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

_get_backend() and _is_backend_available() in tools/web_tools.py used hardcoded env-var checks per known backend, meaning custom web providers registered via the plugin system were never discovered during fallback resolution. This refactors both functions to delegate to agent.web_search_registry.get_provider().is_available(), with a legacy env-var fallback for unregistered providers.

Related Issue

Fixes #28651

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

tools/web_tools.py — 26 insertions, 19 deletions

_get_backend() — replaced hardcoded candidate list with iteration over agent.web_search_registry._LEGACY_PREFERENCE, checking each via _is_backend_available()
_is_backend_available() — first looks up the provider from the registry and calls is_available(), falls back to legacy env-var checks for unregistered providers or when is_available() returns False (preserves test monkeypatch compatibility)

How to Test

  1. add and enable custom web_extract plugin (without any API key for builtin providers)
  2. ask the agent to test web_extract
  3. it should report the tool is available and working

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • [N/A] I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: Docker, Linux

Documentation & Housekeeping

  • [N/A] I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • [N/A] I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • [N/A] I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • [N/A] I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • [N/A] I've updated tool descriptions/schemas if I changed tool behavior — or N/A

iacobs added 3 commits May 19, 2026 10:42
- _is_backend_available() now uses provider.is_available() from web_search_registry
- _get_backend() walks _LEGACY_PREFERENCE via registry with fallback to legacy checks
- Removed redundant _ddgs_package_importable()
- Full backward compat: falls back to env-var checks for unregistered providers
…ockability

Reviewer feedback: keeping the helper function preserves the ability for
tests to monkeypatch a single symbol and retains the documentation comment
explaining why ddgs uses package-presence checks instead of env vars.
…le() returns False

When a provider is registered but is_available() returns False (e.g. ddgs
plugin loaded but package not installed), fall through to the legacy
env-var/package check instead of returning False immediately. This
preserves test monkeypatch ability: tests mock _ddgs_package_importable()
to return True, and the fallback path picks it up correctly.
@m0n5t3r

m0n5t3r commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

huh, maybe I should fix the git data hermes uses (it made up the email address that fails the check)

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/tools Tool registry, model_tools, toolsets tool/web Web search and extraction labels May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/web Web search and extraction type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: web_tools hardcodes provider list and won't load the configured provider if it's not on the list

2 participants