mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-24 17:06:00 +00:00
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:
@@ -1,6 +1,10 @@
|
||||
"""Subagent configuration definitions."""
|
||||
|
||||
from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from deerflow.config.app_config import AppConfig
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -29,3 +33,24 @@ class SubagentConfig:
|
||||
model: str = "inherit"
|
||||
max_turns: int = 50
|
||||
timeout_seconds: int = 900
|
||||
|
||||
|
||||
def _default_model_name(app_config: "AppConfig") -> str:
|
||||
if not app_config.models:
|
||||
raise ValueError("No chat models are configured. Please configure at least one model in config.yaml.")
|
||||
return app_config.models[0].name
|
||||
|
||||
|
||||
def resolve_subagent_model_name(config: SubagentConfig, parent_model: str | None, *, app_config: "AppConfig | None" = None) -> str:
|
||||
"""Resolve the effective model name a subagent should use."""
|
||||
if config.model != "inherit":
|
||||
return config.model
|
||||
|
||||
if parent_model is not None:
|
||||
return parent_model
|
||||
|
||||
if app_config is None:
|
||||
from deerflow.config import get_app_config
|
||||
|
||||
app_config = get_app_config()
|
||||
return _default_model_name(app_config)
|
||||
|
||||
Reference in New Issue
Block a user