From 080a03f3bc1472838ef9ad8ae2a59f79d74dcd33 Mon Sep 17 00:00:00 2001 From: Admire <64821731+LittleChenLiya@users.noreply.github.com> Date: Thu, 26 Mar 2026 14:48:45 +0800 Subject: [PATCH] fix(config): fix summarization model alias resolution (#1378) Co-authored-by: Willem Jiang --- .../deerflow/agents/lead_agent/agent.py | 2 +- .../tests/test_lead_agent_model_resolution.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/backend/packages/harness/deerflow/agents/lead_agent/agent.py b/backend/packages/harness/deerflow/agents/lead_agent/agent.py index 5f66e0a..1bcc0ee 100644 --- a/backend/packages/harness/deerflow/agents/lead_agent/agent.py +++ b/backend/packages/harness/deerflow/agents/lead_agent/agent.py @@ -58,7 +58,7 @@ def _create_summarization_middleware() -> SummarizationMiddleware | None: # Prepare model parameter if config.model_name: - model = config.model_name + model = create_chat_model(name=config.model_name, thinking_enabled=False) else: # Use a lightweight model for summarization to save costs # Falls back to default model if not explicitly specified diff --git a/backend/tests/test_lead_agent_model_resolution.py b/backend/tests/test_lead_agent_model_resolution.py index 9498f04..79ec380 100644 --- a/backend/tests/test_lead_agent_model_resolution.py +++ b/backend/tests/test_lead_agent_model_resolution.py @@ -8,6 +8,7 @@ from deerflow.agents.lead_agent import agent as lead_agent_module from deerflow.config.app_config import AppConfig from deerflow.config.model_config import ModelConfig from deerflow.config.sandbox_config import SandboxConfig +from deerflow.config.summarization_config import SummarizationConfig def _make_app_config(models: list[ModelConfig]) -> AppConfig: @@ -135,3 +136,29 @@ def test_build_middlewares_uses_resolved_model_name_for_vision(monkeypatch): ) assert any(isinstance(m, lead_agent_module.ViewImageMiddleware) for m in middlewares) + + +def test_create_summarization_middleware_uses_configured_model_alias(monkeypatch): + monkeypatch.setattr( + lead_agent_module, + "get_summarization_config", + lambda: SummarizationConfig(enabled=True, model_name="model-masswork"), + ) + + captured: dict[str, object] = {} + fake_model = object() + + def _fake_create_chat_model(*, name=None, thinking_enabled, reasoning_effort=None): + captured["name"] = name + captured["thinking_enabled"] = thinking_enabled + captured["reasoning_effort"] = reasoning_effort + return fake_model + + monkeypatch.setattr(lead_agent_module, "create_chat_model", _fake_create_chat_model) + monkeypatch.setattr(lead_agent_module, "SummarizationMiddleware", lambda **kwargs: kwargs) + + middleware = lead_agent_module._create_summarization_middleware() + + assert captured["name"] == "model-masswork" + assert captured["thinking_enabled"] is False + assert middleware["model"] is fake_model