Skip to content

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

refine code

geekan4bb4dce4b9f4
diff --git a/metagpt/roles/role.py b/metagpt/roles/role.py
index 75dff94f2..959b5d00d 100644
--- a/metagpt/roles/role.py
+++ b/metagpt/roles/role.py
@@ -158,6 +158,7 @@ class Role(SerializationMixin, ConfigMixin, BaseModel):
@staticmethod
def pydantic_rebuild_model():
+ """Rebuild model to avoid `RecursionError: maximum recursion depth exceeded in comparison`"""
from metagpt.environment import Environment
Environment
@@ -165,9 +166,11 @@ class Role(SerializationMixin, ConfigMixin, BaseModel):
@property
def todo(self) -> Action:
+ """Get action to do"""
return self.rc.todo
def set_todo(self, value: Optional[Action]):
+ """Set action to do and update context"""
if value:
value.g_context = self.context
self.rc.todo = value
@@ -181,6 +184,7 @@ class Role(SerializationMixin, ConfigMixin, BaseModel):
@property
def git_repo(self):
+ """Git repo"""
return self.context.git_repo
@git_repo.setter
@@ -189,6 +193,7 @@ class Role(SerializationMixin, ConfigMixin, BaseModel):
@property
def src_workspace(self):
+ """Source workspace under git repo"""
return self.context.src_workspace
@src_workspace.setter
@@ -197,6 +202,7 @@ class Role(SerializationMixin, ConfigMixin, BaseModel):
@property
def prompt_schema(self):
+ """Prompt schema: json/markdown"""
return self.config.prompt_schema
@property
@@ -308,11 +314,6 @@ class Role(SerializationMixin, ConfigMixin, BaseModel):
env.set_addresses(self, self.addresses)
self.llm.system_prompt = self._get_prefix()
- @property
- def action_count(self):
- """Return number of action"""
- return len(self.actions)
-
def _get_prefix(self):
"""Get the role prefix"""
if self.desc:
diff --git a/tests/metagpt/test_role.py b/tests/metagpt/test_role.py
index 20c8dba6d..c67a8ad8a 100644
--- a/tests/metagpt/test_role.py
+++ b/tests/metagpt/test_role.py
@@ -112,7 +112,7 @@ async def test_send_to():
def test_init_action():
role = Role()
role.add_actions([MockAction, MockAction])
- assert role.action_count == 2
+ assert len(role.actions) == 2
@pytest.mark.asyncio