Skip to content

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

fixbug: exceed length

莘权 马f7ebd2a3744b
diff --git a/metagpt/memory/brain_memory.py b/metagpt/memory/brain_memory.py
index c6be2cb7e..a5a3dbfc7 100644
--- a/metagpt/memory/brain_memory.py
+++ b/metagpt/memory/brain_memory.py
@@ -45,7 +45,16 @@ class BrainMemory(pydantic.BaseModel):
def history_text(self):
if len(self.history) == 0:
return ""
- texts = [Message(**m).content for m in self.history[:-1]]
+ texts = []
+ for m in self.history[:-1]:
+ if isinstance(m, Dict):
+ t = Message(**m).content
+ elif isinstance(m, Message):
+ t = m.content
+ else:
+ continue
+ texts.append(t)
+
return "\n".join(texts)
def move_to_solution(self, history_summary):