diff --git a/nanobot/agent/subagent.py b/nanobot/agent/subagent.py index 9e0cd7c..18a4b20 100644 --- a/nanobot/agent/subagent.py +++ b/nanobot/agent/subagent.py @@ -50,6 +50,7 @@ class SubagentManager: self, task: str, label: str | None = None, + model: str | None = None, origin_channel: str = "cli", origin_chat_id: str = "direct", ) -> str: @@ -75,7 +76,7 @@ class SubagentManager: # Create background task bg_task = asyncio.create_task( - self._run_subagent(task_id, task, display_label, origin) + self._run_subagent(task_id, task, display_label, origin, model=model) ) self._running_tasks[task_id] = bg_task @@ -91,6 +92,7 @@ class SubagentManager: task: str, label: str, origin: dict[str, str], + model: str | None = None, ) -> None: """Execute the subagent task and announce the result.""" logger.info(f"Subagent [{task_id}] starting task: {label}") @@ -129,7 +131,7 @@ class SubagentManager: response = await self.provider.chat( messages=messages, tools=tools.get_definitions(), - model=self.model, + model=model or self.model, ) if response.has_tool_calls: diff --git a/nanobot/agent/tools/spawn.py b/nanobot/agent/tools/spawn.py index 5884a07..4b50047 100644 --- a/nanobot/agent/tools/spawn.py +++ b/nanobot/agent/tools/spawn.py @@ -51,15 +51,20 @@ class SpawnTool(Tool): "type": "string", "description": "Optional short label for the task (for display)", }, + "model": { + "type": "string", + "description": "Optional model override for the subagent (e.g. 'claude-sonnet-4-20250514'). Defaults to the main agent's model.", + }, }, "required": ["task"], } - async def execute(self, task: str, label: str | None = None, **kwargs: Any) -> str: + async def execute(self, task: str, label: str | None = None, model: str | None = None, **kwargs: Any) -> str: """Spawn a subagent to execute the given task.""" return await self._manager.spawn( task=task, label=label, + model=model, origin_channel=self._origin_channel, origin_chat_id=self._origin_chat_id, )