diff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.py index 531e60549..6908dc4e5 100644 --- a/nanobot/agent/loop.py +++ b/nanobot/agent/loop.py @@ -217,7 +217,6 @@ class AgentLoop: runtime_events: RuntimeEventBus | None = None, runtime_model_publisher: Callable[[str, str | None], None] | None = None, ): - from nanobot.agent.tools.config import tool_config_by_key from nanobot.config.schema import ToolsConfig _tc = tools_config or ToolsConfig() @@ -255,8 +254,8 @@ class AgentLoop: else defaults.tool_hint_max_length ) self.tools_config = _tc - self.web_config = tool_config_by_key(_tc, "web") - self.exec_config = tool_config_by_key(_tc, "exec") + self.web_config = _tc.web + self.exec_config = _tc.exec self._image_generation_provider_configs = dict(image_generation_provider_configs or {}) if ( image_generation_provider_config is not None @@ -440,7 +439,6 @@ class AgentLoop: def _register_default_tools(self) -> None: """Register the default set of tools via plugin loader.""" - from nanobot.agent.tools.config import tool_config from nanobot.agent.tools.context import ToolContext from nanobot.agent.tools.loader import ToolLoader @@ -461,10 +459,9 @@ class AgentLoop: registered = loader.load(ctx, self.tools) # MyTool needs runtime state reference — manual registration - my_config = tool_config(self.tools_config, MyTool) - if my_config.enable: + if self.tools_config.my.enable: self.tools.register( - MyTool(runtime_state=self, modify_allowed=my_config.allow_set) + MyTool(runtime_state=self, modify_allowed=self.tools_config.my.allow_set) ) registered.append("my") diff --git a/nanobot/agent/subagent.py b/nanobot/agent/subagent.py index 9c02f6082..d93f8419e 100644 --- a/nanobot/agent/subagent.py +++ b/nanobot/agent/subagent.py @@ -115,12 +115,10 @@ class SubagentManager: def _subagent_tools_config(self) -> ToolsConfig: """Build a ToolsConfig scoped for subagent use.""" - from nanobot.agent.tools.config import tool_config_by_key - return ToolsConfig( - exec=tool_config_by_key(self.tools_config, "exec"), - web=tool_config_by_key(self.tools_config, "web"), - file=tool_config_by_key(self.tools_config, "file"), + exec=self.tools_config.exec, + web=self.tools_config.web, + file=self.tools_config.file, restrict_to_workspace=self.restrict_to_workspace, ) diff --git a/nanobot/agent/tools/config.py b/nanobot/agent/tools/config.py index 6311c6b12..ad8be5abc 100644 --- a/nanobot/agent/tools/config.py +++ b/nanobot/agent/tools/config.py @@ -58,17 +58,6 @@ def _materialize_config(config: BaseModel, key: str, config_cls: type[BaseModel] return parsed -def tool_config(config: Any, tool_cls: type[Any]) -> Any: - """Return the parsed config section for one tool class.""" - key = getattr(tool_cls, "config_key", "") - config_cls = tool_cls.config_cls() - if not key or config_cls is None: - return None - if not isinstance(config, BaseModel): - return getattr(config, key) - return _materialize_config(config, key, config_cls) - - def tool_config_by_key(config: Any, key: str) -> Any: """Return the parsed config section for a tool config key.""" if not isinstance(config, BaseModel): diff --git a/nanobot/agent/tools/loader.py b/nanobot/agent/tools/loader.py index 6bcfbf183..36d215703 100644 --- a/nanobot/agent/tools/loader.py +++ b/nanobot/agent/tools/loader.py @@ -97,8 +97,6 @@ class ToolLoader: return plugins def load(self, ctx: Any, registry: ToolRegistry, *, scope: str = "core") -> list[str]: - from nanobot.agent.tools.config import tool_config - registered: list[str] = [] builtin_names: set[str] = set() sources = [(self.discover(), False), (self._discover_plugins().values(), True)] @@ -108,7 +106,6 @@ class ToolLoader: try: if scope not in getattr(tool_cls, "_scopes", {"core"}): continue - tool_config(ctx.config, tool_cls) if not tool_cls.enabled(ctx): continue tool = tool_cls.create(ctx)