Skip to content

Commit 4a29cd3

Browse files
committed
[chore][conversation][bind memory_md_path to a local so pyre keeps the narrowing]
1 parent b66838a commit 4a29cd3

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

swarms/structs/conversation.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -664,21 +664,19 @@ def rollback(self, checkpoint: Tuple[int, int]):
664664
del self.conversation_history[length:]
665665
self._str_cache = None
666666

667-
if not self.memory_md_path:
667+
path = self.memory_md_path
668+
if not path:
668669
return
669670

670671
try:
671672
with self._memory_md_lock:
672673
if (
673-
os.path.exists(self.memory_md_path)
674-
and os.path.getsize(self.memory_md_path)
675-
> memory_md_size
674+
os.path.exists(path)
675+
and os.path.getsize(path) > memory_md_size
676676
):
677-
os.truncate(self.memory_md_path, memory_md_size)
677+
os.truncate(path, memory_md_size)
678678
except Exception as e:
679-
logger.error(
680-
f"Failed to roll back {self.memory_md_path}: {e}"
681-
)
679+
logger.error(f"Failed to roll back {path}: {e}")
682680

683681
def update(self, index: str, role, content):
684682
"""Update a message in the conversation history.

0 commit comments

Comments
 (0)