Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(subagent): inherit parent tool configuration
chengyongru84d96d8a1eca
diff --git a/nanobot/agent/subagent.py b/nanobot/agent/subagent.pyindex cfdb64df0..26b3965fd 100644--- a/nanobot/agent/subagent.py+++ b/nanobot/agent/subagent.py@@ -507,11 +507,8 @@ class SubagentManager:)def _subagent_tools_config(self) -> ToolsConfig:- return ToolsConfig(- exec=self.tools_config.exec,- web=self.tools_config.web,- file=self.tools_config.file,- restrict_to_workspace=self.restrict_to_workspace,+ return self.tools_config.model_copy(+ update={"restrict_to_workspace": self.restrict_to_workspace},)def _build_tools(diff --git a/tests/agent/test_subagent.py b/tests/agent/test_subagent.pyindex 212759110..0187c58cb 100644--- a/tests/agent/test_subagent.py+++ b/tests/agent/test_subagent.py@@ -7,6 +7,8 @@ import pytestfrom nanobot.agent.memory import Consolidatorfrom nanobot.agent.runner import AgentRunResultfrom nanobot.agent.subagent import SubagentManager+from nanobot.agent.tools.cli_apps import CliAppsTool+from nanobot.agent.tools.cli_apps_config import CliAppsToolConfigfrom nanobot.agent.tools.filesystem import FileToolsConfigfrom nanobot.bus.queue import MessageBusfrom nanobot.config.schema import ToolsConfig@@ -89,6 +91,50 @@ def test_subagent_respects_file_tool_toggle(tmp_path):assert file_tools.isdisjoint(tools.tool_names)[email protected]("project_scoped", [False, True])+async def test_subagent_respects_disabled_cli_apps_in_model_tools(tmp_path, project_scoped, monkeypatch):+ monkeypatch.setattr("nanobot.apps.cli.service.get_runtime_subdir", lambda name: tmp_path / name)+ provider = MagicMock(spec=LLMProvider)+ provider.chat_stream_with_retry = AsyncMock(return_value=LLMResponse(content="done"))+ manager = SubagentManager(+ workspace=tmp_path,+ bus=MessageBus(),+ max_tool_result_chars=16_000,+ consolidator=MagicMock(spec=Consolidator),+ tools_config=ToolsConfig(cli_apps=CliAppsToolConfig(enable=False)),+ )+ scope = build_workspace_scope(tmp_path, "restricted") if project_scoped else None++ result = await manager.run_inline(+ task="inspect the workspace",+ session_key="test:direct",+ runtime=_runtime(provider),+ workspace_scope=scope,+ )++ assert result == "done"+ definitions = provider.chat_stream_with_retry.await_args.kwargs["tools"]+ tool_names = {definition["function"]["name"] for definition in definitions}+ assert "read_file" in tool_names+ assert "run_cli_app" not in tool_names+++def test_subagent_inherits_cli_app_runtime_settings(tmp_path):+ manager = SubagentManager(+ workspace=tmp_path,+ bus=MessageBus(),+ max_tool_result_chars=16_000,+ consolidator=MagicMock(spec=Consolidator),+ tools_config=ToolsConfig(cli_apps=CliAppsToolConfig(run_timeout=17)),+ )++ tool = manager._build_tools().get("run_cli_app")++ assert isinstance(tool, CliAppsTool)+ assert tool.runtime.run_timeout == 17++def test_subagent_prompt_keeps_agent_paths_for_selected_project(tmp_path):agent_workspace = tmp_path / "agent"project = tmp_path / "project"@@ -166,6 +212,8 @@ async def test_subagent_keeps_project_runtime_scope_with_agent_owned_tools(tmp_pspec = manager.runner.run.call_args.args[0]assert spec.workspace == projectassert spec.tools.get("read_file")._workspace == agent_workspace.resolve()+ assert spec.tools.get("read_file")._restrict_to_workspace is True+ assert manager.tools_config.restrict_to_workspace is False@pytest.mark.asyncio