From 1e6e9d3103f759020f311fac6360ab01535a27b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8E=98=E6=9D=83=20=E9=A9=AC?= Date: Thu, 9 May 2024 20:28:33 +0800 Subject: [PATCH] feat: +auto append agent metadata --- metagpt/roles/role.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py index 14aa7dbb5..7e3c85579 100644 --- a/metagpt/roles/role.py +++ b/metagpt/roles/role.py @@ -449,6 +449,8 @@ class Role(SerializationMixin, ContextMixin, BaseModel): if not self.rc.env: # If env does not exist, do not publish the message return + if isinstance(msg, AIMessage) and not msg.agent: + msg.with_agent(self._setting) self.rc.env.publish_message(msg) def put_message(self, message):