Repository navigation
Conversation
…ant turn (#978) The Environment system was spliced right after the first user. When that user was followed by a directive-only system row or another user, the non-empty system ended up in a position upstream rejects ("role 'system' must precede an 'assistant' message or end the array"). Slide the insert point forward to just before the next assistant, or the end of the array. The common user -> assistant shape is unchanged.
Contributor
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: 095174ab-f2a9-4fc2-b912-8610e8e0a02b) |
This was referenced Nov 16, 2026
Owner
Author
|
感谢贡献。替代修复 #1162 已合入 main(1881d65f01)。面板 Environment 移到 assistant 边界;相邻已有正文 system 时合并内容,避免原候选仍可能产生连续两个非空 system。 此 PR 不再重复合并。 |
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.
Fixes #978
问题
insertMidConversationSystem和 persona 的 Environment 注入都把非空role: system插在首条 user 之后。首条 user 后面紧跟 directive-only system(content: []+output_config)或另一条 user 时,非空 system 落在上游不接受的位置:role 'system' must precede an 'assistant' message or end the array。修复
插入点从锚定的 user 往后找,放到下一条 assistant 之前;后面没有 assistant 就放到末尾。常见的 user → assistant 形状位置不变,缓存前缀不受影响。
验证
Note
Medium Risk
Changes message ordering for persona Environment and mid-conversation system injection on outbound API requests; incorrect placement could still cause 400s or cache-prefix shifts, but behavior is narrowed to comply with upstream rules and is regression-tested.
Overview
Non-empty
role: systemmessages were inserted immediately after the first user turn, which breaks when the next message is another user or a directive-only system row (content: []+output_config). Upstream requires non-empty system turns to sit right before an assistant or at the end of the array (#978).This PR adds
systemInsertAt, which anchors on the target user index then advances to the index before the next assistant (ormessages.length).insertMidConversationSystemand official template Environment injection inapplyTemplatePersonaboth use it instead of a fixed “after user” slot. The usual user → assistant layout is unchanged for cache stability.Tests cover directive-adjacent layouts, the classic shape, and tail append when no assistant follows.
Reviewed by Cursor Bugbot for commit aca8c6a. Configure here.