(self)
| 41 | self.history_path = self.path.with_suffix(self.path.suffix + ".history.jsonl") |
| 42 | |
| 43 | def load(self) -> MemoryPolicyState: |
| 44 | if not self.path.exists(): |
| 45 | return MemoryPolicyState() |
| 46 | try: |
| 47 | data = json.loads(self.path.read_text(encoding="utf-8")) |
| 48 | except Exception: |
| 49 | return MemoryPolicyState() |
| 50 | return _state_from_dict(data) |
| 51 | |
| 52 | def save(self, state: MemoryPolicyState, reason: str = "update") -> None: |
| 53 | self.path.parent.mkdir(parents=True, exist_ok=True) |