Skip to main content

MemoryToolkit

A toolkit that provides methods for saving, loading, and clearing a ChatAgent’s memory. These methods are exposed as FunctionTool objects for function calling. Internally, it calls:
  • agent.save_memory(path)
  • agent.load_memory(new_memory_obj)
  • agent.load_memory_from_path(path)
  • agent.clear_memory()
Parameters:
  • agent (ChatAgent): The chat agent whose memory will be managed.
  • timeout (Optional[float], optional): Maximum execution time allowed for toolkit operations in seconds. If None, no timeout is applied. (default: :obj:None)

init

save

Saves the agent’s current memory to a JSON file. Parameters:
  • path (str): The file path to save the memory to.
Returns: str: Confirmation message.

load

Loads memory into the agent from a JSON string. Parameters:
  • memory_json (str): A JSON string containing memory records.
Returns: str: Confirmation or error message.

load_from_path

Loads the agent’s memory from a JSON file. Parameters:
  • path (str): The file path to load the memory from.
Returns: str: Confirmation message.

clear_memory

Returns: str: Confirmation message.

get_tools

Returns: list[FunctionTool]: List of FunctionTool objects.