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)
This commit is contained in:
Stephen Hu 2025-05-26 10:28:46 +08:00 committed by GitHub
parent 1f32e6e4f4
commit ae171956e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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])})