{{ message }}
Repository navigation
Python: preserve instruction order in prepend_instructions_to_messages dedup - #8353
Merged
Evan Mattson (moonbox3) merged 3 commits intoSep 15, 2026
Conversation
…pend_instructions_to_messages When only a prefix of the instruction list is already present as leading messages, the previous dedup logic collected the non-matching remainder and prepended it in front of the matched messages. For instructions ["First", "Second"] with an existing leading system message "First", the result became ["Second", "First", ...] - inverting the relative order of the instructions. Deduplicate only the matching prefix and insert the remaining instructions immediately after it, so the instruction order is preserved. Behavior for the previously tested cases (no match, full match, single instruction) is unchanged.
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 13, 2026 16:49 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 13, 2026 16:49 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 13, 2026 16:49 — with
GitHub Actions
Inactive
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 13, 2026 16:49 — with
GitHub Actions
Inactive
Closed
5 tasks done
Contributor
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 14, 2026 05:20 — with
GitHub Actions
Inactive
Contributor
Author
|
Updated the PR description to the standardized template. Thanks! |
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 14, 2026 05:48 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Sep 14, 2026
Eduard van Valkenburg (eavanvalkenburg)
left a comment
Member
There was a problem hiding this comment.
Looks good—thanks!
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Sep 14, 2026
Contributor
Author
Manohar Paturi (ManoharPaturi)
temporarily deployed
to
github-app-auth
September 14, 2026 15:37 — with
GitHub Actions
Inactive
Evan Mattson (moonbox3)
temporarily deployed
to
github-app-auth
September 15, 2026 01:35 — with
GitHub Actions
Inactive
This branch was previously deployed
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 & Context
prepend_instructions_to_messages()inverts the order of the instruction list when only part of it is already present as leading messages. The dedup added in #5051 prepends the non-matching remainder in front of the matched instructions, so a chat client using["First", "Second"]instructions with a leading system"First"message ends up with the system prompt silently reordered toSecond, First. Reported in #8352.Description & Review Guide
_types.pyand the new ordering test.Related Issue
Fixes #8352
Contribution Checklist