Uh oh!
There was an error while loading. Please reload this page.
fix(opencode): collapse plugin-pushed system messages into one - #38671
Closed
matchaxnb wants to merge 2 commits into
Closed
fix(opencode): collapse plugin-pushed system messages into one#38671matchaxnb wants to merge 2 commits into
matchaxnb wants to merge 2 commits into
Conversation
Contributor
The following comment was made by an LLM, it may be inaccurate: Potential Duplicate FoundPR #34322 - Relationship: This is the exact same fix that PR #38671 supersedes. According to the current PR's description, #38671 addresses the same issue as #34322 but with an additional correction (collapse guard fix that was missing in the previous attempt). Since the current PR explicitly states it "supersedes #34322 by @MADEVAL," these are directly related—#34322 should likely be closed in favor of #38671. |
13 tasks
3 tasks
ondrejch
commented
Aug 15, 2026
matchaxnb
commented
Aug 16, 2026
Author
Oka closing, cheers! |
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 freeto 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.
Issue for this PR
Closes#34321
This supersedes #34322 by @MADEVAL because some further fix was missing (collapse again in the messages)
Type of change
What does this PR do?
When a plugin uses experimental.chat.system.transform to push additional system instructions, the collapse guard
system.length > 2was one too high. The initial array has 1 element and a plugin that pushes 1 entry makes it 2, so2 > 2never fired. The result was multiple {role: "system"} messages, which OpenAI-compatible providers reject.The fix changes the guard from
> 2to> 1. Thesystem[0] === headercheck still protects against intentional header replacement by plugins.How did you verify your code works?
Added a test in transform.test.ts that simulates a plugin pushing to system and verifies the prepared messages array has exactly one system message containing the extra instructions. Traced the full code path: system array construction, plugin trigger, collapse guard, and message construction.
Checklist