MCPcopy Create free account
hub / github.com/ScaleML/AgentSPEX / _load_memory

Function _load_memory

src/sandbox_vm/tools/memory/episodic.py:14–30  ·  view source on GitHub ↗

Load memory from file, return empty dict if file doesn't exist

(memory_file)

Source from the content-addressed store, hash-verified

12
13
14async def _load_memory(memory_file) -> Dict[str, Any]:
15 """Load memory from file, return empty dict if file doesn't exist"""
16
17 try:
18 # Ensure directory exists
19 Path(memory_file).parent.mkdir(parents=True, exist_ok=True)
20
21 if not os.path.exists(memory_file):
22 return {}
23
24 # Read file synchronously (aiofiles would be better but adds dependency)
25 with open(memory_file, "r", encoding="utf-8") as f:
26 return json.load(f)
27 except Exception as e:
28 # If file is corrupted, log error and start fresh
29 print(f"Warning: Could not load memory file {memory_file}: {e}")
30 return {}
31
32
33async def _save_memory(memory_data: Dict[str, Any], memory_file: str) -> bool:

Callers 8

test_store_actionMethod · 0.90
test_clear_actionMethod · 0.90
memoryFunction · 0.85

Calls

no outgoing calls

Tested by 7

test_store_actionMethod · 0.72
test_clear_actionMethod · 0.72