mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Update msg_stack.py (#1820)
* Update msg_stack.py 1、[msg.to_dict() for msg in msgs], msg is not instanse of Message, it not has a func of to_dict(), so msg.to_dict() will accur JSONDecodeError; 2、json.dump(new_data, file), it appends new_data to the end of the file instead of overwriting from the beginning, Hence, it's necessary to first perform file.seek(0) and file.truncate(). * Update opendevin/server/session/msg_stack.py --------- Co-authored-by: Yufan Song <33971064+yufansong@users.noreply.github.com>
This commit is contained in:
parent
15685f9aba
commit
52e21c20e3
@ -99,7 +99,11 @@ class MessageStack:
|
||||
new_data = {}
|
||||
for sid, msgs in data.items():
|
||||
if sid != del_sid:
|
||||
new_data[sid] = [msg.to_dict() for msg in msgs]
|
||||
new_data[sid] = msgs
|
||||
# Move the file pointer to the beginning of the file to overwrite the original contents
|
||||
file.seek(0)
|
||||
# clean previous content
|
||||
file.truncate()
|
||||
json.dump(new_data, file)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user