Skip to content

Building AI agents, atomically

Copy chat history without serializing local schemas

黄耀鑫(Huang Yaoxin)7e1d02cf03c4
diff --git a/atomic-agents/atomic_agents/context/chat_history.py b/atomic-agents/atomic_agents/context/chat_history.py
index b679a74..41ae1af 100644
--- a/atomic-agents/atomic_agents/context/chat_history.py
+++ b/atomic-agents/atomic_agents/context/chat_history.py
@@ -1,5 +1,6 @@
import json
import uuid
+from copy import deepcopy
from enum import Enum
from pathlib import Path
from typing import Dict, List, Optional, Tuple, Type, Union
@@ -201,7 +202,7 @@ class ChatHistory(BaseChatHistory):
ChatHistory: A copy of the chat history.
"""
new_history = ChatHistory(max_messages=self.max_messages)
- new_history.load(self.dump())
+ new_history.history = deepcopy(self.history)
new_history.current_turn_id = self.current_turn_id
return new_history