fix(memory): resolve enum value access and tool processing issues

This commit is contained in:
jinli.yl 2026-02-06 12:16:28 +08:00
parent c5438c52fc
commit 88674c52f9
4 changed files with 28 additions and 22 deletions

View file

@ -61,7 +61,7 @@ class BaseMemoryAgent(BaseReact, metaclass=ABCMeta):
lines = []
for memory_target, memory_type in self.memory_target_type_mapping.items():
line = {
"agent": f"Agent managing {memory_type} memories for {memory_target}",
"agent": f"Agent managing {memory_type.value} memories for {memory_target}",
"memory_target": memory_target,
}
lines.append(json.dumps(line, ensure_ascii=False))

View file

@ -68,25 +68,27 @@ class ReMeRetriever(BaseMemoryAgent):
async def execute(self):
result = await super().execute()
tools: list[BaseTool] = result["tools"]
delegate_task_tool = tools[0]
agents: list[BaseMemoryAgent] = delegate_task_tool.response.metadata["agents"]
answer = []
success = True
messages = []
tools = []
tools_result = []
retrieved_nodes = []
for agent in agents:
answer.append(agent.response.answer)
success = success and agent.response.success
messages.extend(agent.response.metadata["messages"])
tools.extend(agent.response.metadata["tools"])
retrieved_nodes.extend(agent.response.metadata["retrieved_nodes"])
if tools:
delegate_task_tool = tools[0]
agents: list[BaseMemoryAgent] = delegate_task_tool.response.metadata["agents"]
for agent in agents:
answer.append(agent.response.answer)
success = success and agent.response.success
messages.extend(agent.response.metadata["messages"])
tools_result.extend(agent.response.metadata["tools"])
retrieved_nodes.extend(agent.response.metadata["retrieved_nodes"])
return {
"answer": "\n".join(answer),
"success": True,
"messages": messages,
"tools": tools,
"tools": tools_result,
"retrieved_nodes": retrieved_nodes,
}

View file

@ -74,22 +74,25 @@ class ReMeSummarizer(BaseMemoryAgent):
async def execute(self):
result = await super().execute()
tools: list[BaseTool] = result["tools"]
delegate_task_tool = tools[0]
agents: list[BaseMemoryAgent] = delegate_task_tool.response.metadata["agents"]
success = True
messages = []
tools = []
tools_result = []
memory_nodes = []
for agent in agents:
success = success and agent.response.success
messages.extend(agent.response.metadata["messages"])
tools.extend(agent.response.metadata["tools"])
memory_nodes.extend(agent.response.metadata["memory_nodes"])
if tools:
delegate_task_tool = tools[0]
agents: list[BaseMemoryAgent] = delegate_task_tool.response.metadata["agents"]
for agent in agents:
success = success and agent.response.success
messages.extend(agent.response.metadata["messages"])
tools_result.extend(agent.response.metadata["tools"])
memory_nodes.extend(agent.response.metadata["memory_nodes"])
return {
"answer": memory_nodes,
"success": True,
"messages": messages,
"tools": tools,
"tools": tools_result,
}

View file

@ -20,7 +20,7 @@ from .agent.memory import (
)
from .config import ReMeConfigParser
from .core import Application
from .core.enumeration import MemoryType
from .core.enumeration import MemoryType, Role
from .core.schema import Message, MemoryNode
from .tool.memory import (
RetrieveMemory,
@ -294,7 +294,8 @@ class ReMe(Application):
if user_name:
if isinstance(user_name, str):
for message in format_messages:
message.name = user_name
if message.role is Role.USER:
message.name = user_name
self._add_meta_memory(MemoryType.PERSONAL, user_name)
elif isinstance(user_name, list):
for name in user_name: