From 04dcc7624f04090b5b3178e0cf5440d3d493943b Mon Sep 17 00:00:00 2001 From: milkmeat Date: Wed, 11 Dec 2024 18:27:30 +0800 Subject: [PATCH] fix "keep_first_message" to make sure messages are in correct order, described in https://github.com/microsoft/autogen/pull/3178#issuecomment-2530740564 --- autogen/agentchat/contrib/capabilities/transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autogen/agentchat/contrib/capabilities/transforms.py b/autogen/agentchat/contrib/capabilities/transforms.py index ad00d7380db6..c559cf5f7483 100644 --- a/autogen/agentchat/contrib/capabilities/transforms.py +++ b/autogen/agentchat/contrib/capabilities/transforms.py @@ -96,7 +96,7 @@ def apply_transform(self, messages: List[Dict]) -> List[Dict]: if remaining_count == 1: # If there's only 1 slot left and it's a 'tools' message, ignore it. if messages[i].get("role") != "tool": - truncated_messages.insert(1, messages[i]) + truncated_messages.insert(1 if self._keep_first_message else 0, messages[i]) remaining_count -= 1 if remaining_count == 0: