feat: unify web tool config under WebToolsConfig + add web tool toggle controls

- Rename WebSearchConfig references to the new WebToolsConfig root struct that wraps both search config and global proxy settings
- Add 'enable' flag to WebToolsConfig to allow fully disabling all web-related tools (WebSearch, WebFetch) at runtime
- Update AgentLoop and SubagentManager to receive the full web config object instead of separate web_search_config/web_proxy parameters
- Update CLI command initialization to pass the consolidated web config struct instead of split fields
- Change default web search provider from brave to duckduckgo for better out-of-the-box usability (no API key required)
This commit is contained in:
Shiniese committed 2026-03-30 16:22:11 +08:00
1 parent c8c520cc9a
commit 7f1dca3186
4 files changed
+25 -28

No files matched your search

+8 -10
View File
@@ -33,7 +33,7 @@ from nanobot.providers.base import LLMProvider
from nanobot.session.manager import Session, SessionManager
if TYPE_CHECKING:
from nanobot.config.schema import ChannelsConfig, ExecToolConfig, WebSearchConfig
from nanobot.config.schema import ChannelsConfig, ExecToolConfig, WebToolsConfig
from nanobot.cron.service import CronService
@@ -59,8 +59,7 @@ class AgentLoop:
model: str | None = None,
max_iterations: int = 40,
context_window_tokens: int = 65_536,
web_search_config: WebSearchConfig | None = None,
web_proxy: str | None = None,
web_config: WebToolsConfig | None = None,
exec_config: ExecToolConfig | None = None,
cron_service: CronService | None = None,
restrict_to_workspace: bool = False,
@@ -69,7 +68,7 @@ class AgentLoop:
channels_config: ChannelsConfig | None = None,
timezone: str | None = None,
):
from nanobot.config.schema import ExecToolConfig, WebSearchConfig
from nanobot.config.schema import ExecToolConfig, WebToolsConfig
self.bus = bus
self.channels_config = channels_config
@@ -78,8 +77,7 @@ class AgentLoop:
self.model = model or provider.get_default_model()
self.max_iterations = max_iterations
self.context_window_tokens = context_window_tokens
self.web_search_config = web_search_config or WebSearchConfig()
self.web_proxy = web_proxy
self.web_config = web_config or WebToolsConfig()
self.exec_config = exec_config or ExecToolConfig()
self.cron_service = cron_service
self.restrict_to_workspace = restrict_to_workspace
@@ -95,8 +93,7 @@ class AgentLoop:
workspace=workspace,
bus=bus,
model=self.model,
web_search_config=self.web_search_config,
web_proxy=web_proxy,
web_config=self.web_config,
exec_config=self.exec_config,
restrict_to_workspace=restrict_to_workspace,
)
@@ -142,8 +139,9 @@ class AgentLoop:
restrict_to_workspace=self.restrict_to_workspace,
path_append=self.exec_config.path_append,
))
self.tools.register(WebSearchTool(config=self.web_search_config, proxy=self.web_proxy))
self.tools.register(WebFetchTool(proxy=self.web_proxy))
if self.web_config.enable:
self.tools.register(WebSearchTool(config=self.web_config.search, proxy=self.web_config.proxy))
self.tools.register(WebFetchTool(proxy=self.web_config.proxy))
self.tools.register(MessageTool(send_callback=self.bus.publish_outbound))
self.tools.register(SpawnTool(manager=self.subagents))
if self.cron_service: