From da27ef69cede275e1b1d9fb617c4b5f0feb60a64 Mon Sep 17 00:00:00 2001 From: cemde Date: Sun, 22 Mar 2026 12:59:57 +0100 Subject: [PATCH] Fix MessageHistory.to_list() returning mutable reference to_list() returned a direct reference to the internal _messages list, causing simulator logs to contain future conversation messages added after the log entry was created. Return a shallow copy instead. Fixes #5 --- CHANGELOG.md | 6 ++++++ maseval/core/history.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53911dc0..1e3d1d6c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +**Core** + +- Fixed `MessageHistory.to_list()` returning a reference to the internal list instead of a copy, causing simulator logs to contain future conversation messages that hadn't occurred at the time of logging. (PR: #PR_NUMBER_PLACEHOLDER) + ### Added **Core** diff --git a/maseval/core/history.py b/maseval/core/history.py index 49ba8ee6..0703f572 100644 --- a/maseval/core/history.py +++ b/maseval/core/history.py @@ -110,7 +110,7 @@ def to_list(self) -> List[Dict[str, Any]]: Returns: List of message dictionaries in OpenAI format """ - return self._messages + return list(self._messages) def add_message( self,