Skip to content

Fix/修复直接插入 message 会破坏 user assistant 交替出现规则的 bug#371

Closed
rxy1212 wants to merge 4 commits into
shareAI-lab:mainfrom
rxy1212:fix/08-content-compact
Closed

Fix/修复直接插入 message 会破坏 user assistant 交替出现规则的 bug#371
rxy1212 wants to merge 4 commits into
shareAI-lab:mainfrom
rxy1212:fix/08-content-compact

Conversation

@rxy1212

@rxy1212 rxy1212 commented Jun 20, 2026

Copy link
Copy Markdown

修复直接插入 message 会破坏 user assistant 交替出现规则的 bug

rxy1212 added 4 commits June 20, 2026 09:47
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.
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@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.

@rxy1212 rxy1212 changed the title Fix/08-content-compact Fix/修复直接插入 message 会破坏 user assistant 交替出现规则的 bug Jun 20, 2026
@Bill-Billion

Copy link
Copy Markdown
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 不会被拆分,原有实现在实际调用中并不会出错。

如果只是想演示截断处添加无损结构标记的方案,建议保留教学版的简洁性,同时修正上述两处缺陷,并做好三语内容的同步对齐。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants