From 03dd73d7292f06246280388f0f69dd1cad31e73c Mon Sep 17 00:00:00 2001 From: hiphi730 <2941315986@qq.com> Date: Wed, 12 Aug 2026 17:24:00 +0800 Subject: [PATCH] fix: honor send_to in Team.run_project --- metagpt/team.py | 2 +- tests/metagpt/test_team.py | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/metagpt/team.py b/metagpt/team.py index 5a98388850..d7bd58afbc 100644 --- a/metagpt/team.py +++ b/metagpt/team.py @@ -104,7 +104,7 @@ def run_project(self, idea, send_to: str = ""): self.idea = idea # Human requirement. - self.env.publish_message(Message(content=idea)) + self.env.publish_message(Message(content=idea, send_to=send_to)) def start_project(self, idea, send_to: str = ""): """ diff --git a/tests/metagpt/test_team.py b/tests/metagpt/test_team.py index a97fc78bf6..69276fdf6d 100644 --- a/tests/metagpt/test_team.py +++ b/tests/metagpt/test_team.py @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- # @Desc : unittest of team +from metagpt.const import MESSAGE_ROUTE_TO_ALL from metagpt.roles.project_manager import ProjectManager from metagpt.team import Team @@ -11,3 +12,22 @@ def test_team(): company.hire([ProjectManager()]) assert len(company.env.roles) == 1 + + +def test_run_project_send_to(): + company = Team(use_mgx=False) + + company.run_project("A test idea", send_to="Alex") + + message = company.env.history.get(k=1)[0] + assert message.content == "A test idea" + assert message.send_to == {"Alex"} + + +def test_run_project_broadcast_by_default(): + company = Team(use_mgx=False) + + company.run_project("A test idea") + + message = company.env.history.get(k=1)[0] + assert message.send_to == {MESSAGE_ROUTE_TO_ALL}