Fix/修复直接插入 message 会破坏 user assistant 交替出现规则的 bug#371
Closed
rxy1212 wants to merge 4 commits into
Closed
Conversation
Add context compression and notification for snipped messages.
Enhance context compression by adding system notes and deep copying messages.
Add context compression for message history in README.
Add boundary guard for message trimming in context compression.
|
@rxy1212 is attempting to deploy a commit to the crazyboym's projects Team on Vercel. A member of the Team first needs to authorize it. |
Collaborator
|
感谢提交这份 PR,但是你的PR引入了新的缺陷,当 tail_start 因边界回退指向 assistant 消息时,System Note 会被插入到 assistant turn中,造成语义错位;同时 msg.copy() 为浅拷贝,list 分支的 .insert() 操作会原地修改调用方传入的原始 messages 列表,与注释里 “深拷贝防污染” 的初衷相悖。其次,在issue题目中提到的“会破坏 user/assistant 消息交替结构” 的前提并不成立。现有 Messages API 会自动合并连续同角色消息为同一轮次,不会触发 400 报错;且原代码的两处边界守卫已保障 tool_use 与 tool_result 不会被拆分,原有实现在实际调用中并不会出错。 如果只是想演示截断处添加无损结构标记的方案,建议保留教学版的简洁性,同时修正上述两处缺陷,并做好三语内容的同步对齐。 |
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.
修复直接插入 message 会破坏 user assistant 交替出现规则的 bug