fix(subagents): use model override for tools and middleware (#2641)

* fix(subagents): use model override for tools and middleware

* fix(config): resolve effective subagent model

* fix(subagents): defer app config loading

* fix(subagents): fully defer config.yaml load in executor __init__

The previous attempt only relocated the explicit get_app_config() call,
but left resolve_subagent_model_name(...) running eagerly in __init__.
That helper has its own internal get_app_config() fallback, which still
fired when both app_config and parent_model were None and
config.model == "inherit" — exactly the path unit tests hit, breaking
21 tests in CI with FileNotFoundError: config.yaml.

Skip the eager resolve in __init__ when it would require loading the
config file, and defer to _create_agent (which already has the
app_config or get_app_config() fallback).
This commit is contained in:
Nan Gao
2026-05-01 16:21:10 +02:00
committed by GitHub
parent c09c334544
commit 487c1d939f
7 changed files with 219 additions and 39 deletions
@@ -11,9 +11,16 @@ from langgraph.config import get_stream_writer
from langgraph.typing import ContextT
from deerflow.agents.thread_state import ThreadState
from deerflow.config import get_app_config
from deerflow.sandbox.security import LOCAL_BASH_SUBAGENT_DISABLED_MESSAGE, is_host_bash_allowed
from deerflow.subagents import SubagentExecutor, get_available_subagent_names, get_subagent_config
from deerflow.subagents.executor import SubagentStatus, cleanup_background_task, get_background_task_result, request_cancel_background_task
from deerflow.subagents.config import resolve_subagent_model_name
from deerflow.subagents.executor import (
SubagentStatus,
cleanup_background_task,
get_background_task_result,
request_cancel_background_task,
)
logger = logging.getLogger(__name__)
@@ -129,14 +136,19 @@ async def task_tool(
# Inherit parent agent's tool_groups so subagents respect the same restrictions
parent_tool_groups = metadata.get("tool_groups")
app_config = None
if config.model == "inherit" and parent_model is None:
app_config = get_app_config()
effective_model = resolve_subagent_model_name(config, parent_model, app_config=app_config)
# Subagents should not have subagent tools enabled (prevent recursive nesting)
tools = get_available_tools(model_name=parent_model, groups=parent_tool_groups, subagent_enabled=False)
tools = get_available_tools(model_name=effective_model, groups=parent_tool_groups, subagent_enabled=False)
# Create executor
executor = SubagentExecutor(
config=config,
tools=tools,
app_config=app_config,
parent_model=parent_model,
sandbox_state=sandbox_state,
thread_data=thread_data,