Python: move _ensure_message_ids higher in the chain to avoid duplicate message ids#5238
Draft
jorge-wonolo wants to merge 1 commit intomicrosoft:mainfrom
Draft
Python: move _ensure_message_ids higher in the chain to avoid duplicate message ids#5238jorge-wonolo wants to merge 1 commit intomicrosoft:mainfrom
jorge-wonolo wants to merge 1 commit intomicrosoft:mainfrom
Conversation
|
@jorge-wonolo please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
Fixes #5237
_ensure_message_idsassignsf"msg_{index}"whereindexcomes fromenumerateover the list it receives.annotate_message_groupscalls it indirectly viagroup_messages(messages[start_index:])on a slice, soenumeraterestarts from 0 on every incremental call — producing IDs that collide with the preserved prefix.The most visible failure is in
SummarizationStrategy:_group_id_forderivesgroup_idfrommessage_id, socolliding IDs collapse distinct groups into one.
Description
Move the
_ensure_message_ids(messages)call fromgroup_messages()(which operates on a slice) to the top ofannotate_message_groups()(which holds the full list). This ensures every message is indexed against thecomplete conversation, producing stable, unique IDs across incremental calls.
Changes:
_compaction.py: Remove_ensure_message_idscall fromgroup_messages, add it at the top ofannotate_message_groupsbefore any slicing occurs.test_compaction.py: Add regression testtest_annotate_message_groups_assigns_unique_ids_after_incremental_callsthat simulates multi-turn incrementalannotation and asserts all
message_ids remain unique.Contribution Checklist
Guidelines