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>