Skip to content

🌟 The Multi-Agent Framework: First AI Software Company, Towards Natural Language Programming

feat: Role有2个动作(action-A和action-B),role是否应该通过给自己发消息触发内部动作循环/执行

莘权 马3ad3882bd889
diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py
index 80a4d6744..b6f6b7d20 100644
--- a/metagpt/roles/role.py
+++ b/metagpt/roles/role.py
@@ -443,6 +443,9 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
"""If the role belongs to env, then the role's messages will be broadcast to env"""
if not msg:
return
+ if all(to in {any_to_str(self), self.name} for to in msg.send_to): # Message to myself
+ self.put_message(msg)
+ return
if not self.rc.env:
# If env does not exist, do not publish the message
return