Skip to content

The agent that grows with you

fix(web): pick own key or Nous Tool Gateway per web capability in Desktop

Teknium3861f1da624f
diff --git a/agent/web_search_registry.py b/agent/web_search_registry.py
index a07180e9a23..242cc91b5c7 100644
--- a/agent/web_search_registry.py
+++ b/agent/web_search_registry.py
@@ -50,8 +50,12 @@ def _read_config_key(*path: str) -> Optional[str]:
def _configured_backend(capability: str) -> Optional[str]:
- """``web.<capability>_backend`` (preferred) or ``web.backend`` (shared fallback)."""
- return _read_config_key("web", f"{capability}_backend") or _read_config_key("web", "backend")
+ """``web.<capability>_backend`` (preferred) or ``web.backend`` (shared fallback). The managed ``nous``
+ selection names no provider: it is served by Perplexity (search) and Firecrawl (extract)."""
+ configured = _read_config_key("web", f"{capability}_backend") or _read_config_key("web", "backend")
+ if configured and configured.lower() == "nous":
+ return "perplexity" if capability == "search" else "firecrawl"
+ return configured
# Paid providers first so existing paid setups don't get downgraded to a free
diff --git a/apps/desktop/src/app/settings/toolset-config-panel.test.tsx b/apps/desktop/src/app/settings/toolset-config-panel.test.tsx
index d5daa6ca3cb..b862ef36d7f 100644
--- a/apps/desktop/src/app/settings/toolset-config-panel.test.tsx
+++ b/apps/desktop/src/app/settings/toolset-config-panel.test.tsx
@@ -1,11 +1,11 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
-import { cleanup, fireEvent, render as rtlRender, screen, waitFor } from '@testing-library/react'
+import { cleanup, fireEvent, render as rtlRender, screen, waitFor, within } from '@testing-library/react'
import type { ReactElement } from 'react'
import { MemoryRouter } from 'react-router'
import type * as ReactRouterDom from 'react-router'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import type { ToolsetConfig } from '@/types/hermes'
+import type { ToolsetConfig, WebCapability } from '@/types/hermes'
// Collect the component graph before the behavioral test deadline starts.
import { ToolsetConfigPanel } from './toolset-config-panel'
@@ -910,7 +910,10 @@ describe('ToolsetConfigPanel', () => {
}
it('hides "Use for Extract" on a search-only provider and wires capability selection', async () => {
- getToolsetConfig.mockResolvedValue(webConfig())
+ // The panel refetches after a capability pick: second load is the server's truth.
+ getToolsetConfig
+ .mockResolvedValueOnce(webConfig())
+ .mockResolvedValue(webConfig({ active_search_backend: 'firecrawl' }))
selectToolsetProvider.mockResolvedValue({ ok: true, name: 'web', provider: 'SearXNG', capability: 'search' })
render(<ToolsetConfigPanel onConfiguredChange={vi.fn()} toolset="web" />)
@@ -926,8 +929,46 @@ describe('ToolsetConfigPanel', () => {
fireEvent.click(useForSearch)
await waitFor(() => expect(selectToolsetProvider).toHaveBeenCalledWith('web', 'Firecrawl', 'search'))
- // Badge tracks the local write without a refetch.
await waitFor(() => expect(screen.getByText('Search: firecrawl')).toBeTruthy())
})
+
+ it('lights the Nous row for a gateway-served capability and the BYOK row for the own-key one', async () => {
+ const nous = {
+ name: 'Nous Subscription',
+ badge: 'subscription',
+ tag: 'Managed web search and extract billed to your subscription',
+ env_vars: [],
+ post_setup: null,
+ requires_nous_auth: true,
+ managed_nous_feature: 'web',
+ is_active: false,
+ status: 'ready' as const,
+ web_backend: 'firecrawl',
+ capabilities: ['search', 'extract'] as WebCapability[]
+ }
+
+ // Search through the gateway, extract on the user's own Firecrawl key:
+ // both rows share web_backend 'firecrawl', only the *_via_nous flags tell them apart.
+ getToolsetConfig.mockResolvedValue(
+ webConfig({
+ active_search_backend: 'perplexity',
+ active_extract_backend: 'firecrawl',
+ search_via_nous: true,
+ extract_via_nous: false,
+ providers: [...webConfig().providers, nous]
+ })
+ )
+
+ render(<ToolsetConfigPanel onConfiguredChange={vi.fn()} toolset="web" />)
+
+ expect(await screen.findByText('Search: Nous subscription')).toBeTruthy()
+ expect(screen.getByText('Extract: firecrawl')).toBeTruthy()
+ const nousRow = screen.getByRole('button', { name: /Nous Subscription/ })
+ const byokRow = screen.getByRole('button', { name: /^Firecrawl/ })
+ expect(within(nousRow).getByText('Search backend')).toBeTruthy()
+ expect(within(nousRow).queryByText('Extract backend')).toBeNull()
+ expect(within(byokRow).getByText('Extract backend')).toBeTruthy()
+ expect(within(byokRow).queryByText('Search backend')).toBeNull()
+ })
})
})
diff --git a/apps/desktop/src/app/settings/toolset-config-panel.tsx b/apps/desktop/src/app/settings/toolset-config-panel.tsx
index 176342cdcb1..f643ac11e19 100644
--- a/apps/desktop/src/app/settings/toolset-config-panel.tsx
+++ b/apps/desktop/src/app/settings/toolset-config-panel.tsx
@@ -99,6 +99,19 @@ function providerStatus(provider: ToolProvider, envState: Record<string, boolean
return providerConfigured(provider, envState) ? 'ready' : 'needs_keys'
}
+/**
+ * Whether a web provider row serves a capability right now. The managed
+ * "Nous Subscription" row and the BYOK Firecrawl rows resolve to the same
+ * backend name, so the server's `*_via_nous` flag decides which one is lit.
+ */
+function capabilityServedBy(provider: ToolProvider, backend: null | string | undefined, viaNous?: boolean): boolean {
+ if (provider.managed_nous_feature) {
+ return Boolean(viaNous)
+ }
+
+ return Boolean(provider.web_backend && backend === provider.web_backend && !viaNous)
+}
+
interface EnvVarFieldProps {
envVar: ToolEnvVar
isSet: boolean
@@ -725,19 +738,24 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
setSelecting(provider.name)
try {
- await selectToolsetProvider(toolset, provider.name, capability, profile)
- // Mirror the backend write locally so the Search:/Extract: badges track
- // the new per-capability backend without a refetch.
- setCfg(current =>
- current
- ? {
- ...current,
- ...(capability === 'search'
- ? { active_search_backend: provider.web_backend ?? provider.name }
- : { active_extract_backend: provider.web_backend ?? provider.name })
- }
- : current
- )
+ const result = await selectToolsetProvider(toolset, provider.name, capability, profile)
+
+ if (result.needs_nous_auth) {
+ notify({
+ kind: 'warning',
+ title: copy.nousAuthNeededTitle,
+ message: copy.nousAuthNeededMessage(provider.name),
+ action: { label: copy.nousAuthSignIn, onClick: () => void signInToNousPortal() }
+ })
+ await refresh()
+
+ return
+ }
+
+ // Refetch rather than mirror: whether the capability now rides the Nous
+ // Tool Gateway or the user's own key is resolved server-side (the
+ // managed and BYOK Firecrawl rows share one web_backend).
+ await refresh()
notify({
kind: 'success',
title: copy.selectedTitle,
@@ -781,8 +799,16 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
// (web.search_backend / web.extract_backend) — show which backend
// each capability resolves to right now.
<div className="flex flex-wrap items-center gap-2 px-1">
- <Pill>{copy.webSearchActive(cfg.active_search_backend || copy.webCapabilityUnset)}</Pill>
- <Pill>{copy.webExtractActive(cfg.active_extract_backend || copy.webCapabilityUnset)}</Pill>
+ <Pill>
+ {copy.webSearchActive(
+ cfg.search_via_nous ? copy.webViaNous : cfg.active_search_backend || copy.webCapabilityUnset
+ )}
+ </Pill>
+ <Pill>
+ {copy.webExtractActive(
+ cfg.extract_via_nous ? copy.webViaNous : cfg.active_extract_backend || copy.webCapabilityUnset
+ )}
+ </Pill>
</div>
)}
{providers.map(provider => {
@@ -790,8 +816,8 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
const isBackendActive = provider.is_active || cfg?.active_provider === provider.name
const status = providerStatus(provider, envState)
const webCaps = toolset === 'web' ? (provider.capabilities ?? []) : []
- const isSearchBackend = Boolean(provider.web_backend && cfg.active_search_backend === provider.web_backend)
- const isExtractBackend = Boolean(provider.web_backend && cfg.active_extract_backend === provider.web_backend)
+ const isSearchBackend = capabilityServedBy(provider, cfg.active_search_backend, cfg.search_via_nous)
+ const isExtractBackend = capabilityServedBy(provider, cfg.active_extract_backend, cfg.extract_via_nous)
return (
<div className="overflow-hidden rounded-xl bg-background/60" key={provider.name}>
@@ -883,7 +909,9 @@ export function ToolsetConfigPanel({ toolset, onConfiguredChange, profile }: Too
</div>
)}
{provider.requires_nous_auth && (
- <p className="text-[0.72rem] text-muted-foreground">{copy.nousIncluded}</p>
+ <p className="text-[0.72rem] text-muted-foreground">
+ {status === 'needs_auth' ? copy.nousIncluded : copy.nousManagedHint}
+ </p>
)}
{provider.env_vars.length === 0 ? (
<p className="text-[0.72rem] text-muted-foreground">{copy.noApiKeyRequired}</p>
diff --git a/apps/desktop/src/i18n/en.ts b/apps/desktop/src/i18n/en.ts
index cec308d4b0c..651100057d8 100644
--- a/apps/desktop/src/i18n/en.ts
+++ b/apps/desktop/src/i18n/en.ts
@@ -2274,6 +2274,7 @@ export const en: Translations = {
activeBackend: 'Active',
activeBackendHint: 'This is your active backend',
useBackend: 'Use this backend',
+ nousManagedHint: 'Runs through the Nous Tool Gateway, billed to your subscription — no API key needed.',
nousIncluded: 'Included with a Nous subscription — sign in with your Nous account to activate.',
nousAuthNeededTitle: 'Sign in with your Nous account',
nousAuthNeededMessage: provider =>
@@ -2303,6 +2304,7 @@ export const en: Translations = {
postSetupFailed: step => `Failed to run ${step} setup`,
webSearchActive: backend => `Search: ${backend}`,
webExtractActive: backend => `Extract: ${backend}`,
+ webViaNous: 'Nous subscription',
webCapabilityUnset: 'not set',
webUseForSearch: 'Use for Search',
webUseForExtract: 'Use for Extract',
diff --git a/apps/desktop/src/i18n/types.ts b/apps/desktop/src/i18n/types.ts
index 7645d14cd8f..bb180f6bb3b 100644
--- a/apps/desktop/src/i18n/types.ts
+++ b/apps/desktop/src/i18n/types.ts
@@ -1913,6 +1913,7 @@ export interface Translations {
activeBackend: string
activeBackendHint: string
useBackend: string
+ nousManagedHint: string
nousIncluded: string
nousAuthNeededTitle: string
nousAuthNeededMessage: (provider: string) => string
@@ -1939,6 +1940,7 @@ export interface Translations {
postSetupFailed: (step: string) => string
webSearchActive: (backend: string) => string
webExtractActive: (backend: string) => string
+ webViaNous: string
webCapabilityUnset: string
webUseForSearch: string
webUseForExtract: string
diff --git a/apps/desktop/src/i18n/zh.ts b/apps/desktop/src/i18n/zh.ts
index e9416cc3185..d7111160e77 100644
--- a/apps/desktop/src/i18n/zh.ts
+++ b/apps/desktop/src/i18n/zh.ts
@@ -2130,6 +2130,7 @@ export const zh = defineLocale({
activeBackend: '当前后端',
activeBackendHint: '这是你当前使用的后端',
useBackend: '使用此后端',
+ nousManagedHint: '通过 Nous Tool Gateway 运行,费用计入你的订阅,无需 API 密钥。',
nousIncluded: '包含在 Nous 订阅中;登录 Nous Portal 即可激活。',
nousAuthNeededTitle: '登录 Nous Portal',
nousAuthNeededMessage: provider => `已保存 ${provider},但在登录 Nous Portal 之前不会激活。`,
@@ -2152,6 +2153,7 @@ export const zh = defineLocale({
postSetupFailed: step => `运行 ${step} 设置失败`,
webSearchActive: backend => `搜索:${backend}`,
webExtractActive: backend => `提取:${backend}`,
+ webViaNous: 'Nous 订阅',
webCapabilityUnset: '未设置',
webUseForSearch: '用于搜索',
webUseForExtract: '用于提取',
diff --git a/apps/desktop/src/types/hermes.ts b/apps/desktop/src/types/hermes.ts
index f2a3851404e..69b4cba8a97 100644
--- a/apps/desktop/src/types/hermes.ts
+++ b/apps/desktop/src/types/hermes.ts
@@ -1257,6 +1257,9 @@ export interface ToolProvider {
/** Web toolset only: capabilities this backend can serve. Search-only
* providers (ddgs, brave-free) report ['search']. */
capabilities?: WebCapability[]
+ /** Set on the "Nous Subscription" rows (e.g. 'web'): served through the
+ * Nous Tool Gateway rather than the user's own key. */
+ managed_nous_feature?: null | string
}
/** A web toolset capability — the runtime dispatches web_search and
@@ -1274,6 +1277,10 @@ export interface ToolsetConfig {
active_search_backend?: string | null
/** Web toolset only: backend the web_extract tool resolves to right now. */
active_extract_backend?: string | null
+ /** Web toolset only: web_search / web_extract currently go through the Nous
+ * Tool Gateway (billed to the subscription) instead of the user's own key. */
+ search_via_nous?: boolean
+ extract_via_nous?: boolean
}
/** Health status of a terminal execution backend row.
diff --git a/hermes_cli/nous_subscription.py b/hermes_cli/nous_subscription.py
index 6fe87cd3d47..e1b2c7b7398 100644
--- a/hermes_cli/nous_subscription.py
+++ b/hermes_cli/nous_subscription.py
@@ -275,7 +275,8 @@ def _web_feature(web_cfg: Dict[str, object], tool_enabled: bool, managed: bool,
"perplexity": _any_env("PERPLEXITY_API_KEY") and not web_gw,
"searxng": _any_env("SEARXNG_URL"),
}
- web_managed = backend == "firecrawl" and managed and not direct_firecrawl
+ web_managed = managed and (
+ (backend == "firecrawl" and not direct_firecrawl) or "nous" in {search_backend, extract_backend})
active = web_managed or direct.get(backend) or direct.get(search_backend) or (extract_backend in ("tavily", "perplexity") and direct[extract_backend])
return _state(
"web", available=bool(managed or any(direct.values())), active=bool(tool_enabled and active),
diff --git a/hermes_cli/tools_config_providers.py b/hermes_cli/tools_config_providers.py
index bb9aa772cdd..a1721524440 100644
--- a/hermes_cli/tools_config_providers.py
+++ b/hermes_cli/tools_config_providers.py
@@ -718,6 +718,11 @@ def _write_provider_config(provider: dict, config: dict, *, managed_feature) ->
if provider.get("web_backend"):
web_cfg = _select_into(config, "web", "backend", provider["web_backend"], managed_feature)
+ if managed_feature:
+ # A whole-toolset managed pick governs both capabilities: per-capability pins resolve FIRST,
+ # so a leftover one would keep outranking the "nous" selection just written.
+ web_cfg.pop("search_backend", None)
+ web_cfg.pop("extract_backend", None)
tier = provider.get("web_tier")
tiers = web_cfg.setdefault("provider_tier", {}) if tier else web_cfg.get("provider_tier")
if isinstance(tiers, dict):
diff --git a/hermes_cli/web_routers/tools.py b/hermes_cli/web_routers/tools.py
index dc1604f82e9..845cbff966e 100644
--- a/hermes_cli/web_routers/tools.py
+++ b/hermes_cli/web_routers/tools.py
@@ -382,6 +382,9 @@ async def get_toolset_config(name: str, profile: Optional[str] = None):
"env_vars": env_vars,
"post_setup": prov.get("post_setup"),
"requires_nous_auth": bool(prov.get("requires_nous_auth")),
+ # Set on the "Nous Subscription" rows: the GUI tells the gateway row apart
+ # from a BYOK row of the same vendor (both carry web_backend "firecrawl").
+ "managed_nous_feature": prov.get("managed_nous_feature"),
"is_active": is_active,
# Server-side readiness: zero-env-var rows are NOT
# automatically ready (logged-out Nous rows, never-run
@@ -402,17 +405,25 @@ async def get_toolset_config(name: str, profile: Optional[str] = None):
"name": name, "has_category": cat is not None, "providers": providers,
"active_provider": active_provider}
if name == "web":
- # Resolve active backends exactly as the web_search/web_extract
- # dispatchers do, so badges reflect what a call would hit now.
+ # Resolve active backends exactly as the web_search/web_extract dispatchers do, so badges
+ # reflect what a call would hit now — plus whether that call rides the Nous Tool Gateway
+ # or the user's own key (the managed and BYOK Firecrawl rows share one backend name).
try:
- from tools.web_tools import _get_extract_backend, _get_search_backend
+ from plugins.web.firecrawl.provider import is_managed_route
+ from tools.web_tools import _get_extract_backend, _get_search_backend, _managed_web_search
search_backend = _get_search_backend()
extract_backend = _get_extract_backend()
+ search_managed = _managed_web_search() or (
+ search_backend == "firecrawl" and is_managed_route("search"))
+ extract_managed = extract_backend == "firecrawl" and is_managed_route("extract")
except Exception:
search_backend = extract_backend = None
+ search_managed = extract_managed = False
payload["active_search_backend"] = search_backend
payload["active_extract_backend"] = extract_backend
+ payload["search_via_nous"] = bool(search_managed)
+ payload["extract_via_nous"] = bool(extract_managed)
return payload
return await asyncio.to_thread(_read)
@@ -536,7 +547,12 @@ async def select_toolset_provider(
raise _bad_request(f"Provider {body.provider!r} has no web backend key")
if body.capability not in web_provider_capabilities(backend):
raise _bad_request(f"{body.provider} does not support {body.capability}")
- _dict_section(config, "web")[f"{body.capability}_backend"] = backend
+ # The managed row's web_backend names the vendor serving it ("firecrawl"); writing that
+ # would read as the user's OWN Firecrawl key. Its pin is "nous" (gateway route).
+ from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER
+
+ _dict_section(config, "web")[f"{body.capability}_backend"] = (
+ NOUS_MANAGED_PROVIDER if prov.get("managed_nous_feature") else backend)
else:
try:
apply_provider_selection(name, body.provider, config)
diff --git a/plugins/web/firecrawl/provider.py b/plugins/web/firecrawl/provider.py
index 9363a9596e6..12d6286a83f 100644
--- a/plugins/web/firecrawl/provider.py
+++ b/plugins/web/firecrawl/provider.py
@@ -91,15 +91,16 @@ def _is_explicit_firecrawl_selection() -> bool:
return _web_config_selects("firecrawl")
-def _use_keyless_ring() -> bool:
+def _use_keyless_ring(capability: Optional[str] = None) -> bool:
"""Route via the keyless ring only with no direct credentials, when the managed Nous
- gateway isn't the selected path, and the keyless tier isn't disabled or pinned paid."""
+ gateway isn't the selected path for *capability*, and the keyless tier isn't disabled or pinned paid."""
if _env("FIRECRAWL_API_KEY") or _env("FIRECRAWL_API_URL"):
return False
- from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_selection
+ from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_web_capability_selection
from plugins.web.keyless_mcp import use_keyless
# Both probes are optional layers: a failing probe never blocks the ring.
- for probe in (lambda: read_selection("web") == NOUS_MANAGED_PROVIDER, lambda: _is_tool_gateway_ready() and not _is_explicit_firecrawl_selection()):
+ for probe in (lambda: read_web_capability_selection(capability) == NOUS_MANAGED_PROVIDER,
+ lambda: _is_tool_gateway_ready() and not _is_explicit_firecrawl_selection()):
try:
if probe():
return False
@@ -141,25 +142,40 @@ def _is_tool_gateway_ready() -> bool:
def check_firecrawl_api_key() -> bool:
"""True when the route selected via ``hermes tools`` (or, on a never-configured
install, either route) is usable."""
- from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_selection
- selected = read_selection("web")
- if selected == NOUS_MANAGED_PROVIDER:
- return _is_tool_gateway_ready()
- return _get_direct_firecrawl_config() is not None or (selected is None and _is_tool_gateway_ready())
+ from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_web_capability_selection
+
+ def _usable(selected) -> bool:
+ if selected == NOUS_MANAGED_PROVIDER:
+ return _is_tool_gateway_ready()
+ return _get_direct_firecrawl_config() is not None or (selected is None and _is_tool_gateway_ready())
+
+ # Search and extract can each pick their route (own key vs gateway); usable if either one is.
+ return any(_usable(read_web_capability_selection(cap)) for cap in ("search", "extract"))
+
+
+def is_managed_route(capability: Optional[str] = None) -> bool:
+ """True when Firecrawl calls for *capability* go through the Nous Tool Gateway rather than the user's
+ own key / instance — the same decision :func:`_get_firecrawl_client` makes, without building a client."""
+ from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_web_capability_selection
+ selected = read_web_capability_selection(capability)
+ if selected is not None or _is_explicit_firecrawl_selection():
+ return selected == NOUS_MANAGED_PROVIDER
+ return _get_direct_firecrawl_config() is None and _is_tool_gateway_ready()
def _firecrawl_backend_help_suffix() -> str:
return ", or use the Nous Tool Gateway via your subscription (FIRECRAWL_GATEWAY_URL or TOOL_GATEWAY_DOMAIN)" if _backend_helpers.managed_nous_tools_enabled() else ""
-def _get_firecrawl_client() -> Any:
- """Get or create the cached Firecrawl client. Strict selection semantics on the stored ``web`` selection:
- ``"nous"`` → managed Tool Gateway ONLY; any other stored backend → direct Firecrawl ONLY (never a silent
- managed fallback billed to Nous); never-configured → direct when present, else managed. Raises ValueError
- when the resolved path is unusable."""
+def _get_firecrawl_client(capability: Optional[str] = None) -> Any:
+ """Get or create the cached Firecrawl client. Strict selection semantics on the stored selection for
+ *capability* (``web.<capability>_backend``, else the shared ``web`` selection): ``"nous"`` → managed Tool
+ Gateway ONLY; any other stored backend → direct Firecrawl ONLY (never a silent managed fallback billed to
+ Nous); never-configured → direct when present, else managed. Raises ValueError when the resolved path is
+ unusable."""
wt = _wt()
- from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_selection, selection_error
- selected = read_selection("web")
+ from tools.tool_backend_helpers import NOUS_MANAGED_PROVIDER, read_web_capability_selection, selection_error
+ selected = read_web_capability_selection(capability)
direct_config = _get_direct_firecrawl_config()
def _managed():
@@ -269,7 +285,7 @@ async def _scrape_one(url: str, formats: List[str], format: Optional[str]) -> Di
# client-side wait expires. See #43272.
scrape_result = await asyncio.wait_for(
asyncio.to_thread(
- _get_firecrawl_client().scrape,
+ _get_firecrawl_client("extract").scrape,
url=url,
formats=formats,
timeout=60_000,
@@ -316,10 +332,10 @@ class FirecrawlWebSearchProvider(BaseWebSearchProvider):
from tools.interrupt import is_interrupted
if is_interrupted():
return search_fail("Interrupted")
- if _use_keyless_ring():
+ if _use_keyless_ring("search"):
return keyless_search("Firecrawl", "firecrawl", query, limit, logger)
logger.info("Firecrawl search: '%s' (limit=%d)", query, limit)
- client = _get_firecrawl_client()
+ client = _get_firecrawl_client("search")
try:
web_results = _extract_web_search_results(client.search(query=query, limit=limit))
logger.info("Firecrawl: found %d search results", len(web_results))
@@ -334,7 +350,7 @@ class FirecrawlWebSearchProvider(BaseWebSearchProvider):
from tools.interrupt import is_interrupted as _is_interrupted
if _is_interrupted():
return [{"url": u, "error": "Interrupted", "title": ""} for u in urls]
- if _use_keyless_ring():
+ if _use_keyless_ring("extract"):
return await asyncio.to_thread(keyless_extract, "Firecrawl", "firecrawl", urls, logger)
format = kwargs.get("format")
formats = [format] if format in ("markdown", "html") else ["markdown", "html"]
diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.py
index 9157381ec55..24324afe5d1 100644
--- a/tests/hermes_cli/test_web_server.py
+++ b/tests/hermes_cli/test_web_server.py
@@ -7,6 +7,7 @@ import re
import shutil
import sys
import threading
+import types
import time
from pathlib import Path
from unittest.mock import patch, MagicMock
@@ -3388,6 +3389,37 @@ class TestNewEndpoints:
assert data["active_extract_backend"] == "firecrawl"
+ def test_web_capability_picks_choose_own_key_or_nous_gateway(self, monkeypatch):
+ """Each web capability picks its own route: "Use for Extract" on the Nous Subscription row must
+ send extract through the Tool Gateway while search keeps the user's own Firecrawl key — and the
+ toolset-level Nous pick must take both back. Before the fix the managed pick wrote "firecrawl",
+ which reads as the BYOK key, so the gateway was unreachable per capability."""
+ import plugins.web.firecrawl.provider as fc
+ import tools.web_tools as wt
+
+ monkeypatch.setenv("FIRECRAWL_API_KEY", "fc-own-key")
+ monkeypatch.setattr(fc._gateway, "resolve_managed_tool_gateway", lambda *a, **k: types.SimpleNamespace(
+ nous_user_token="nous-tok", gateway_origin="https://firecrawl-gateway.example"))
+ monkeypatch.setattr(fc, "Firecrawl", lambda **kw: types.SimpleNamespace(kwargs=kw), raising=False)
+ monkeypatch.setattr(wt, "_firecrawl_client", None, raising=False)
+
+ def put(**body):
+ assert self.client.put("/api/tools/toolsets/web/provider", json=body).status_code == 200
+ return self.client.get("/api/tools/toolsets/web/config").json()
+
+ put(provider="Firecrawl", capability="search")
+ data = put(provider="Nous Subscription", capability="extract")
+ assert (data["search_via_nous"], data["extract_via_nous"]) == (False, True)
+ assert fc._get_firecrawl_client("search").kwargs["api_key"] == "fc-own-key"
+ assert fc._get_firecrawl_client("extract").kwargs["api_key"] == "nous-tok"
+
+ data = put(provider="Nous Subscription")
+ from hermes_cli.config import load_config
+ web = load_config()["web"]
+ assert not web.get("search_backend") and not web.get("extract_backend")
+ assert (data["search_via_nous"], data["extract_via_nous"]) == (True, True)
+
+
# -- Terminal execution backend picker ---------------------------------
diff --git a/tools/tool_backend_helpers.py b/tools/tool_backend_helpers.py
index 3e0a3bd464b..0f4060d505a 100644
--- a/tools/tool_backend_helpers.py
+++ b/tools/tool_backend_helpers.py
@@ -233,6 +233,19 @@ def read_selection(section: str) -> str | None:
return None
+def read_web_capability_selection(capability: Optional[str] = None) -> str | None:
+ """Stored selection that decides ONE web capability (``"search"`` / ``"extract"``):
+ ``web.<capability>_backend`` when set (``"nous"`` = managed gateway, a vendor name =
+ that vendor direct), else the shared :func:`read_selection`. Lets search and extract
+ each choose between the user's own key and the Nous Tool Gateway."""
+ if capability:
+ raw = _raw_section("web") or {}
+ pin = str(raw.get(f"{capability}_backend") or "").strip().lower()
+ if pin:
+ return pin
+ return read_selection("web")
+
+
def selection_exists(section: str) -> bool:
"""True when ANY selection signal was ever written for the section (wider than
read_selection: per-capability web keys count too)."""
diff --git a/tools/web_tools.py b/tools/web_tools.py
index 7e7beb8d673..f4768597103 100644
--- a/tools/web_tools.py
+++ b/tools/web_tools.py
@@ -156,12 +156,14 @@ def _keyless_backend() -> Optional[str]:
def _managed_web_search() -> bool:
- """True when web_search is on the managed Nous route: the stored ``nous`` selection, or a
- never-configured install whose autodetect lands on the gateway — the entitled Firecrawl gateway, or
- free Perplexity fast search for any Nous identity when nothing else is configured (search-only: the
- extract ladder is untouched). A stored vendor selection never is."""
- if _configured_backend("search_backend"):
- return False
+ """True when web_search is on the managed Nous route: the stored ``nous`` selection (a
+ ``web.search_backend: nous`` pin, else the shared one), or a never-configured install whose
+ autodetect lands on the gateway — the entitled Firecrawl gateway, or free Perplexity fast search
+ for any Nous identity when nothing else is configured (search-only: the extract ladder is
+ untouched). A stored vendor selection never is."""
+ search_pin = _configured_backend("search_backend")
+ if search_pin:
+ return search_pin == NOUS_MANAGED_PROVIDER
selected = read_selection("web")
if selected is not None:
return selected == NOUS_MANAGED_PROVIDER
@@ -174,14 +176,19 @@ def _managed_web_search() -> bool:
def _get_search_backend() -> str:
"""Backend for web_search: ``web.search_backend`` (strict, no probe) > ``web.backend`` > autodetect.
- The managed Nous route serves search from Perplexity (extract stays on Firecrawl); managed Firecrawl
- is the per-call fallback, see ``_memoized_search``."""
- return _configured_backend("search_backend") or ("perplexity" if _managed_web_search() else _get_backend())
+ The managed Nous route (a ``nous`` pin or shared selection) serves search from Perplexity (extract
+ stays on Firecrawl); managed Firecrawl is the per-call fallback, see ``_memoized_search``."""
+ pin = _configured_backend("search_backend")
+ if pin and pin != NOUS_MANAGED_PROVIDER:
+ return pin
+ return "perplexity" if _managed_web_search() else _get_backend()
def _get_extract_backend() -> str:
- """Backend for web_extract: ``web.extract_backend`` (strict, no probe) > ``web.backend`` > autodetect."""
- return _configured_backend("extract_backend") or _get_backend()
+ """Backend for web_extract: ``web.extract_backend`` (strict, no probe) > ``web.backend`` > autodetect.
+ A ``nous`` pin is managed Firecrawl; the client picks the gateway route for that capability."""
+ pin = _configured_backend("extract_backend")
+ return "firecrawl" if pin == NOUS_MANAGED_PROVIDER else pin or _get_backend()
def _ddgs_package_importable() -> bool:
diff --git a/website/docs/user-guide/features/tool-gateway.md b/website/docs/user-guide/features/tool-gateway.md
index 05d6b45337c..08b88881e7d 100644
--- a/website/docs/user-guide/features/tool-gateway.md
+++ b/website/docs/user-guide/features/tool-gateway.md
@@ -167,6 +167,18 @@ web:
backend: firecrawl # Hermes now uses FIRECRAWL_API_KEY from .env
```
+### Mixing your own key and the gateway (web only)
+
+Web search and web extract can each choose their own route. In the desktop app, open **Capabilities → Tools → Web Search & Scraping**: **Use for Search** / **Use for Extract** on the **Nous Subscription** row sends that capability through the gateway, and the same buttons on a direct row (e.g. **Firecrawl**) send it through your own key. The **Search:** / **Extract:** pills at the top show which route each one takes right now. In `config.yaml` the managed choice is the value `nous` on the per-capability key:
+
+```yaml
+web:
+ search_backend: firecrawl # your FIRECRAWL_API_KEY
+ extract_backend: nous # the Nous Tool Gateway (managed Firecrawl)
+```
+
+Picking **Nous Subscription** for the whole tool (or running `hermes tools`) clears both per-capability keys, so search and extract both go back through the gateway.
+
### Legacy `use_gateway` flag (deprecated)
Older Hermes versions used a per-tool `use_gateway: true` boolean to route through the gateway. That flag is **legacy**: it is never written anymore, and the `hermes tools` picker removes it from a category's config when it rewrites the selection. Old configs that still contain `use_gateway: true` are interpreted at read time as the `nous` selection, so existing setups keep working. Don't set `use_gateway` in new configs — select the provider in `hermes tools` instead.
diff --git a/website/docs/user-guide/features/web-search.md b/website/docs/user-guide/features/web-search.md
index 719a9396082..c8125c220b9 100644
--- a/website/docs/user-guide/features/web-search.md
+++ b/website/docs/user-guide/features/web-search.md
@@ -426,7 +426,7 @@ web:
When a per-capability key is empty, that capability falls through to `web.backend`. Only when no **shared** web selection has ever been written (`web.backend` or the managed `hermes tools` row) is the backend auto-detected from whichever API key/URL is present — once a shared selection exists, the runtime always uses it, and adding a key to `.env` does not reroute web traffic. A per-capability key affects only its own capability: setting `web.extract_backend` alone leaves `web_search` on its auto-detected backend.
**Priority order (per capability):**
-1. `web.search_backend` / `web.extract_backend` (explicit per-capability)
+1. `web.search_backend` / `web.extract_backend` (explicit per-capability; `nous` = managed Tool Gateway for that capability only, see [Tool Gateway](./tool-gateway.md#mixing-your-own-key-and-the-gateway-web-only))
2. `web.backend` (shared fallback; `nous` = managed Tool Gateway)
3. Auto-detect from environment variables (no shared selection written)