Skip to content

fix(web): SearXNG honors SEARXNG_URL set via hermes config (#34290)#34367

Closed
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/34290-searxng-config-aware-env
Closed

fix(web): SearXNG honors SEARXNG_URL set via hermes config (#34290)#34367
Bartok9 wants to merge 1 commit into
NousResearch:mainfrom
Bartok9:fix/34290-searxng-config-aware-env

Conversation

@Bartok9

@Bartok9 Bartok9 commented May 29, 2026

Copy link
Copy Markdown
Contributor

Closes #34290

Problem

SearXNG provider read os.getenv(SEARXNG_URL) only. Users who set the URL via hermes config set SEARXNG_URL ... or the Hermes-managed .env file got SEARXNG_URL is not set — those values are visible through hermes_cli.config.get_env_value() but NOT necessarily exported to the running process env (gateway worker spawned via systemd, etc.).

Same blind spot in tools/web_tools.py::_has_env (drives auto-backend selection at line 156).

Fix

  1. plugins/web/searxng/provider.py — new _resolve_searxng_url() helper: get_env_value() first, os.getenv() fallback. Used by both is_available() and search() so they can never disagree.

  2. tools/web_tools.py — same config-first lookup in _has_env. Diagnostic print at line 1196 also config-aware.

POSIX behavior preserved for users who set via shell exports / systemd Environment=.

Tests (5 new)

$ python -m pytest tests/tools/test_web_providers_searxng.py
=== 29 passed in 0.35s ===

🎻 Co-authored-by: Cursor cursoragent@cursor.com

…rch#34290)

SearXNG provider read os.getenv(SEARXNG_URL) only. Users who set the
URL via 'hermes config set SEARXNG_URL ...' or via the Hermes-managed
.env file got 'SEARXNG_URL is not set' because the live process env
was unchanged \u2014 those values are visible through
hermes_cli.config.get_env_value() but are NOT necessarily exported to
the running process environment.

The same blind spot existed in tools/web_tools.py's _has_env helper
that drives the auto-backend selection at line 156. After this fix,
both layers agree on availability.

Changes:

1. plugins/web/searxng/provider.py
   New _resolve_searxng_url() helper: try get_env_value() first, then
   os.getenv() fallback. Used by both is_available() and search() so
   they can never disagree. When both have a value, config wins \u2014
   because 'hermes config set' is the user's authoritative
   declaration.

2. tools/web_tools.py
   _has_env() now does the same config-first lookup. The auto-backend
   selection at line 156 (and the same logic at line 216) now find
   SearXNG when it was set via config. The diagnostic print at line
   1196 also uses the config-aware resolution so 'hermes tools' shows
   the actual URL the provider will use, not a stale shell value.

POSIX behavior preserved for users who set SEARXNG_URL via shell
exports / systemd Environment= \u2014 the os.getenv fallback still works
identically.

Tests (5 new in TestSearXNGConfigAwareEnvResolution):

- Provider picks up SEARXNG_URL from get_env_value() when os.environ
  is empty (the NousResearch#34290 reproduction case).
- Provider falls back to process env when config has nothing (legacy
  shell-export behavior preserved).
- Provider reports unavailable when neither layer has a value.
- _resolve_searxng_url prefers config over env when both are set.
- tools/web_tools.py::_has_env is also config-aware for SEARXNG_URL
  so the backend selection logic agrees with the provider.

All 29 tests in test_web_providers_searxng.py pass.

Refs: NousResearch#34290
Closes: NousResearch#34290

Co-authored-by: Cursor <cursoragent@cursor.com>
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have tool/web Web search and extraction comp/plugins Plugin system and bundled plugins labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competes with #34300 and #34306 — all fix SearXNG config-aware env lookup (#34290). This PR has broadest scope (provider.py + web_tools._has_env + diagnostic print). #34300 also covers web_tools; #34306 only provider.py.

@Bartok9

Bartok9 commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of #34306 (@Kailigithub), which makes the same SearXNG provider fix and is smaller + earlier.

Differential: my PR also fixed tools/web_tools.py::_has_env so the auto-backend selection at line 156 honors Hermes config too \u2014 without that, SearXNG works when explicitly configured but won't be auto-selected by the backend-priority cascade. #34306 doesn't touch that path.

If maintainers consider the _has_env config-awareness in scope for #34290, happy to resubmit just that change as a focused follow-up after #34306 lands. Not pushing it pre-emptively to avoid further dup-noise.

\u2014 Bartok9

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

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have 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: SearXNG provider ignores Hermes config env values for SEARXNG_URL

2 participants