MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / __init__

Method __init__

src/memory/context.py:34–70  ·  view source on GitHub ↗

Initialize the memory context manager. Args: base_dir: Base directory for storing memory data save_path: Path to save memory configurations contract_path: Path to save memory contract

(self, 
                 base_dir: Optional[str] = None,
                 save_path: Optional[str] = None,
                 contract_path: Optional[str] = None,
                 **kwargs)

Source from the content-addressed store, hash-verified

32 contract_path: str = Field(default=None, description="The path to save the memory contract")
33
34 def __init__(self,
35 base_dir: Optional[str] = None,
36 save_path: Optional[str] = None,
37 contract_path: Optional[str] = None,
38 **kwargs):
39 """Initialize the memory context manager.
40
41 Args:
42 base_dir: Base directory for storing memory data
43 save_path: Path to save memory configurations
44 contract_path: Path to save memory contract
45 """
46 super().__init__(**kwargs)
47
48 if base_dir is not None:
49 self.base_dir = assemble_project_path(base_dir)
50 else:
51 self.base_dir = assemble_project_path(os.path.join(config.workdir, "memory"))
52 logger.info(f"| 📁 Memory context manager base directory: {self.base_dir}.")
53 os.makedirs(self.base_dir, exist_ok=True)
54 if save_path is not None:
55 self.save_path = assemble_project_path(save_path)
56 else:
57 self.save_path = os.path.join(self.base_dir, "memory.json")
58 logger.info(f"| 📁 Memory context manager save path: {self.save_path}.")
59 if contract_path is not None:
60 self.contract_path = assemble_project_path(contract_path)
61 else:
62 self.contract_path = os.path.join(self.base_dir, "contract.md")
63 logger.info(f"| 📁 Memory context manager contract path: {self.contract_path}.")
64
65 self._memory_configs: Dict[str, MemoryConfig] = {} # Current active configs (latest version)
66 # Memory version history, e.g., {"memory_name": {"1.0.0": MemoryConfig, "1.0.1": MemoryConfig}}
67 self._memory_history_versions: Dict[str, Dict[str, MemoryConfig]] = {}
68
69 self._cleanup_registered = False
70 self._variables_lock = asyncio.Lock() # Lock for get/set trainable variables
71
72 async def initialize(self, memory_names: Optional[List[str]] = None):
73 """Initialize the memory context manager."""

Callers

nothing calls this directly

Calls 3

assemble_project_pathFunction · 0.90
joinMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected