fix(web_tools): trigger plugin discovery before registry dispatch (#27683) - #27700
Closed
luyao618 wants to merge 1 commit into
Closed
fix(web_tools): trigger plugin discovery before registry dispatch (#27683)#27700luyao618 wants to merge 1 commit into
luyao618 wants to merge 1 commit into
Conversation
…usResearch#27683) The three web tool dispatchers — `web_search_tool`, `web_extract_tool`, and `web_crawl_tool` — resolve providers via `agent.web_search_registry`. On a fresh install (or any path that hasn't already triggered plugin discovery for some unrelated reason) the registry is empty, so every `get_provider()` / `get_active_*_provider()` call returns `None` and the user sees a 'no provider configured' fallback even when they have a backend installed and configured correctly. `tools/image_generation_tool.py` and `tools/video_generation_tool.py` already guard against this by lazily importing and calling `hermes_cli.plugins._ensure_plugins_discovered()` before consulting their registries. `web_tools.py` did not. Mirror that pattern at all three dispatch sites — lazy import inside a try/except so we still work in slim/test environments where `hermes_cli` isn't importable. Discovery is idempotent and cheap on subsequent calls. Regression test `tests/tools/test_web_tools_plugin_discovery.py` patches `_ensure_plugins_discovered` and asserts each of the three entrypoints invokes it. Verified the three tests fail on main and pass with this patch. Fixes NousResearch#27683
Collaborator
bbernstein616
approved these changes
May 18, 2026
bbernstein616
left a comment
There was a problem hiding this comment.
Watchdog review: independently checked the patch and ran targeted verification locally. The change matches the existing image/video lazy plugin-discovery pattern, keeps import-order risk low, and all CI checks are green. Local verification: scripts/run_tests.sh tests/tools/test_web_tools_plugin_discovery.py (3 passed) and python -m ruff check tests/tools/test_web_tools_plugin_discovery.py tools/web_tools.py (passed). I attempted to merge, but this token/user lacks MergePullRequest permission.
Contributor
Author
|
Closing as duplicate of #27584 (same |
This was referenced Aug 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #27683.
tools/web_tools.pydispatches to providers fromagent.web_search_registryat three sites —web_search_tool(~L797),web_extract_tool(~L935), andweb_crawl_tool(~L1193) — without first callinghermes_cli.plugins._ensure_plugins_discovered().On a fresh install (or any session where plugin discovery hasn't already been triggered for some unrelated reason), the registry is empty.
get_provider()andget_active_*_provider()therefore returnNone, and the user gets a "No web search/extract/crawl provider configured" error envelope — or a silent fallback — even though they have a backend (e.g.ddgs) installed and configured.The sibling tools
tools/image_generation_tool.pyandtools/video_generation_tool.pyboth already guard against this exact failure mode by lazily importing and calling_ensure_plugins_discovered()before consulting their respective registries (seeimage_generation_tool.py:874,video_generation_tool.py:207).web_tools.pywas the outlier.Fix
Mirror the existing pattern at all three dispatch sites — a 6-line
try/exceptblock immediately before theagent.web_search_registryimport:except Exceptionso the path still works in slim/test environments wherehermes_cliisn't importable (matches the defensive style inimage_generation_tool.py)._ensure_plugins_discovered()short-circuits after the first run.Tests
New file
tests/tools/test_web_tools_plugin_discovery.pyadds three regression tests, one per dispatcher. Each patcheshermes_cli.plugins._ensure_plugins_discovered, forces the registry to returnNone(so the tool short-circuits quickly), and asserts the discovery hook was invoked.I verified both directions:
Scope
tools/web_tools.py— 18 lines added (three 6-line blocks), no other edits, no formatting churn.tests/tools/test_web_tools_plugin_discovery.py— new file, 111 lines.Risk
Very low. Discovery is already invoked by image/video tools on every call; this brings web tools in line. The
try/except Exceptionkeeps the slim-environment path safe.