From ae171956e85edf29193b0287563ece0e52bf6005 Mon Sep 17 00:00:00 2001 From: Stephen Hu Date: Mon, 26 May 2025 10:28:46 +0800 Subject: [PATCH] Fix:Setting the message_history_window_size to 0 does not take effect (#7842) ### What problem does this PR solve? Close #7830 The caller method should already have code to handle this. ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- agent/canvas.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/agent/canvas.py b/agent/canvas.py index 7fc642456..8e94c639c 100644 --- a/agent/canvas.py +++ b/agent/canvas.py @@ -304,6 +304,8 @@ class Canvas: def get_history(self, window_size): convs = [] + if window_size <= 0: + return convs for role, obj in self.history[window_size * -1:]: if isinstance(obj, list) and obj and all([isinstance(o, dict) for o in obj]): convs.append({"role": role, "content": '\n'.join([str(s.get("content", "")) for s in obj])})