Skip to content

Commit

Permalink
fix "keep_first_message" to make sure messages are in correct order, …
Browse files Browse the repository at this point in the history
…(#4653)

described in microsoft/autogen#3178 (comment)

Co-authored-by: Eric Zhu <[email protected]>
  • Loading branch information
amaziatower and ekzhu committed Dec 12, 2024
1 parent bc22adf commit 427a98d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion autogen/agentchat/contrib/capabilities/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 427a98d

Please sign in to comment.