fix(agent): Fix long-term memory error (#2644)

# Description

Closes #2642
Closes #2637

# How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration

# Snapshots:

Include snapshots for easier review.

# Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have already rebased the commits and make the commit message
conform to the project standard.
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [x] I have made corresponding changes to the documentation
- [x] Any dependent changes have been merged and published in downstream
modules
This commit is contained in:
magic.chen 2025-04-23 13:49:55 +08:00 committed by GitHub
commit e78d5370ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 3 deletions

View File

@ -69,7 +69,7 @@ class HybridMemory(Memory, Generic[T]):
@classmethod
def from_chroma(
cls,
vstore_name: Optional[str] = "_chroma_agent_memory_",
vstore_name: Optional[str] = "agent_memory_long_term",
vstore_path: Optional[str] = None,
embeddings: Optional[Embeddings] = None,
executor: Optional[Executor] = None,

View File

@ -102,6 +102,7 @@ class ToolPack(ResourcePack):
args: Optional[Dict[str, Any]] = None,
function: Optional[Callable] = None,
parse_execute_args_func: Optional[PARSE_EXECUTE_ARGS_FUNCTION] = None,
overwrite: bool = False,
) -> None:
"""Add a command to the commands.
@ -118,6 +119,8 @@ class ToolPack(ResourcePack):
the command is executed. Defaults to None.
parse_execute_args (callable, optional): A callable function to parse the
execute arguments. Defaults to None.
overwrite (bool, optional): Whether to overwrite the command if it already
exists. Defaults to False.
"""
if args is not None:
tool_args = {}
@ -151,7 +154,7 @@ class ToolPack(ResourcePack):
description=command_label,
parse_execute_args_func=parse_execute_args_func,
)
self.append(ft)
self.append(ft, overwrite=overwrite)
def _get_execution_tool(
self,
@ -347,6 +350,7 @@ class MCPToolPack(ToolPack):
ssl_verify: Optional[Dict[str, Union[ssl.SSLContext, str, bool]]] = None,
default_ssl_verify: Union[ssl.SSLContext, str, bool] = True,
default_ssl_cafile: Optional[str] = None,
overwrite_same_tool: bool = True,
**kwargs,
):
"""Create an Auto-GPT plugin tool pack."""
@ -363,6 +367,7 @@ class MCPToolPack(ToolPack):
self._default_ssl_verify = default_ssl_verify
self._ssl_verify_map = ssl_verify or {}
self.server_ssl_verify_map = {}
self._overwrite_same_tool = overwrite_same_tool
def switch_mcp_input_schema(self, input_schema: dict):
args = {}
@ -450,5 +455,6 @@ class MCPToolPack(ToolPack):
args,
call_mcp_tool,
parse_execute_args_func=json_parse_execute_args_func,
overwrite=self._overwrite_same_tool,
)
self._loaded = True

View File

@ -142,7 +142,7 @@ class MultiAgents(BaseComponent, ABC):
).create()
storage_manager = StorageManager.get_instance(self.system_app)
index_name = "_agent_memory_"
index_name = "agent_memory_long_term"
vector_store = storage_manager.create_vector_store(index_name=index_name)
if not vector_store.vector_name_exists():
vector_store.create_collection(collection_name=index_name)