From 6bd1726422ca7aa5b8cec14c491ee833ca32c0c1 Mon Sep 17 00:00:00 2001 From: Bartok Moltbot Date: Tue, 10 Mar 2026 23:45:05 -0700 Subject: [PATCH] feat(subagent): add configurable subagent model via config.yaml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow users to configure a dedicated model for subagents spawned by delegate_task, so narrowly-scoped subtasks can use a cheaper/faster model while the parent agent runs on a more powerful one. Config: subagent: model: google/gemini-3-flash-preview Precedence: explicit model arg > config.subagent.model > parent model. Cherry-picked from PR #751 by Bartok9, rebased onto current main with conflict resolution and simplified to model-only override (provider/base_url/api_key stay inherited from parent — covers the common case of same-provider model swap via OpenRouter). Closes #609 Co-authored-by: Bartok Moltbot --- hermes_cli/config.py | 7 +++++++ tools/delegate_tool.py | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/hermes_cli/config.py b/hermes_cli/config.py index ccf3debc16..e0778b03c3 100644 --- a/hermes_cli/config.py +++ b/hermes_cli/config.py @@ -119,6 +119,13 @@ DEFAULT_CONFIG = { }, }, + # Subagent configuration — model/provider for tasks spawned via delegate_task. + # By default subagents inherit the parent agent's model and provider. + # Set "model" to use a cheaper/faster model for delegated subtasks. + "subagent": { + # "model": "google/gemini-3-flash-preview", + }, + "display": { "compact": False, "personality": "kawaii", diff --git a/tools/delegate_tool.py b/tools/delegate_tool.py index 835b46afeb..6c88551072 100644 --- a/tools/delegate_tool.py +++ b/tools/delegate_tool.py @@ -78,6 +78,15 @@ def _strip_blocked_tools(toolsets: List[str]) -> List[str]: return [t for t in toolsets if t not in blocked_toolset_names] +def _get_subagent_config() -> Dict[str, Any]: + """Load subagent config from CLI_CONFIG if available.""" + try: + from cli import CLI_CONFIG + return CLI_CONFIG.get("subagent", {}) + except Exception: + return {} + + def _build_child_progress_callback(task_index: int, parent_agent, task_count: int = 1) -> Optional[callable]: """Build a callback that relays child agent tool calls to the parent display. @@ -199,10 +208,15 @@ def _run_single_child( # count toward the session-wide limit. shared_budget = getattr(parent_agent, "iteration_budget", None) + # Subagent model override from config. + # Precedence: explicit model arg > config.subagent.model > parent model + subagent_cfg = _get_subagent_config() + effective_model = model or subagent_cfg.get("model") or parent_agent.model + child = AIAgent( base_url=parent_agent.base_url, api_key=parent_api_key, - model=model or parent_agent.model, + model=effective_model, provider=getattr(parent_agent, "provider", None), api_mode=getattr(parent_agent, "api_mode", None), max_iterations=max_iterations,