refactor: increase memory recall limit and improve formatting

- Updated memory recall limit from 5 to 10 in the Agent class to enhance memory retrieval capabilities.
- Improved formatting of memory output by changing the join method to use double newlines for better readability in multiple locations.
This commit is contained in:
Joao Moura
2026-02-26 00:38:33 -08:00
parent 358fd92e6b
commit 01df1ef3cf
3 changed files with 10 additions and 6 deletions

View File

@@ -384,9 +384,9 @@ class Agent(BaseAgent):
)
if unified_memory is not None:
query = task.description
matches = unified_memory.recall(query, limit=5)
matches = unified_memory.recall(query, limit=10)
if matches:
memory = "Relevant memories:\n" + "\n".join(
memory = "Relevant memories:\n" + "\n\n".join(
m.format() for m in matches
)
if memory.strip() != "":
@@ -1811,10 +1811,10 @@ class Agent(BaseAgent):
),
)
start_time = time.time()
matches = agent_memory.recall(formatted_messages, limit=5)
matches = agent_memory.recall(formatted_messages, limit=10)
memory_block = ""
if matches:
memory_block = "Relevant memories:\n" + "\n".join(
memory_block = "Relevant memories:\n" + "\n\n".join(
m.format() for m in matches
)
if memory_block:

View File

@@ -100,7 +100,11 @@ class MemoryMatch(BaseModel):
if self.record.metadata:
for key, value in self.record.metadata.items():
if value:
lines.append(f" {key}: {value}")
if isinstance(value, list):
rendered_value = ", ".join(str(item) for item in value)
else:
rendered_value = str(value)
lines.append(f" {key}: {rendered_value}")
return "\n".join(lines)

View File

@@ -57,7 +57,7 @@ class RecallMemoryTool(BaseTool):
if not all_lines:
return "No relevant memories found."
return "Found memories:\n" + "\n".join(all_lines)
return "Found memories:\n" + "\n\n".join(all_lines)
class RememberSchema(BaseModel):