Repository navigation
fix(chat): resume conversations after skill installation - #1260
Open
Robert0622 wants to merge 2 commits into
Open
Robert0622 wants to merge 2 commits into
Robert0622 wants to merge 2 commits into
Conversation
newexploreor
left a comment
Collaborator
There was a problem hiding this comment.
Code Review
整体 LGTM。定位准确,改动收敛,安全边界没有放松。下面有两条建议和一个小 nit,都不阻塞合入。
已确认的点
- 技能目录根和祖先路径仍然做全量校验:
WalkDir先判断ModeSymlink再走SkipDir,所以home/.agents/skills本身是链接、或者home/.agents是链接时,仍然会被拒绝。TestConversationAssetResetHandlesInstalledSkillLink的后半段覆盖了这种情况。 - 跳过技能目录内部校验后,没有任何路径会穿过链接读写:
- 控制面在
chat和openAssistantNativeSession里跳过当前引擎的技能目录,紧接着writeConversationAssets会用RemoveAll把整棵树重建。RemoveAll不跟随链接,所以不会伤到ws/里的目标文件。 - runner 侧的
prepare不读技能文件;resetAssets是在lockAssets加锁、并确认进程未运行之后才RemoveAll,不存在 TOCTOU。 sync和start仍然做全量校验;conversationInputFiles本来也会跳过链接。
- 控制面在
- 本地验证:在 PR 分支上,
internal/runtime(Conversation*)和internal/httpapi(SharedNativeSession|ConversationAsset|Subagent|SharedDirectChat)都能通过,internal/httpapi整包也通过。把实现回退到 main、只保留新增测试后,两条新用例都会失败:一条报prepare failed ... home/.agents/skills/installed,另一条报 409,说明它们确实能复现原问题。internal/runtime整包跑时,TestAgentStateMountsAndDockerManagerReclaim失败过一次。这个用例在 PR 分支上单独跑三次都能通过,看起来是 fake docker 在并发跑时的偶发失败,和本 PR 无关。
建议
- 控制面只放过当前引擎的技能目录,切换引擎后可能还会 409。
assistant.go和openAssistantNativeSession只把assistantConversationSkillTree(req.Model)传给了ValidateConversationRoot。设想这样一个场景:共享会话先用 CodeBuddy,CLI 在home/.codebuddy/skills/下装了一个链接;之后同一会话切到 Codex。openAssistantNativeSession的 contextHash 里包含 engine,所以这种切换是支持的。但这时.codebuddy/skills不在放行列表里,也不会被writeConversationAssets重建,于是每一轮都会报“共享会话缓存不可用”,而且没法自愈。
可选的修法:控制面也放行全部conversationSkillTrees,并在writeConversationAssets里顺手RemoveAll掉非当前引擎的技能目录(runner 的resetAssets已经是这样做的,两边规则也就一致了)。如果确认“一个会话固定一个 CLI”,至少补一句注释说明这个前提。 - 安装的技能会在下一轮从 CLI home 里消失,需要确认这是预期行为。
新测试断言home/.../skills/installed这个别名会被删掉。也就是说,用户在工作区里用npx skills add -g之类的方式装到全局的技能,下一轮就从 CLI home 里看不到了,只剩ws/.agents/skills/installed。如果对应 CLI 会扫描项目级的ws/.agents/skills,那就没问题;否则用户会觉得“装了的技能又没了”。建议在 PR 描述里写明这个行为,或者确认几个引擎都能从 ws 目录发现技能。
Nit
conversation_assets.go:refreshingSkills对每个遍历到的条目都要算两次slices.Contains。可以把它挪到entry.IsDir()分支里再算,读起来也更直观:
if entry.IsDir() && (rel == "ws" || slices.Contains(refreshedSkillTrees, rel) && slices.Contains(conversationSkillTrees, rel)) {
return filepath.SkipDir
}
1 task done
crispinhu27
approved these changes
Nov 23, 2026
crispinhu27
left a comment
Collaborator
There was a problem hiding this comment.
Code Review — APPROVE
审查范围(head 5252fe03,base 52560f49,初审)
本 PR 对 ValidateConversationRoot 增加了 replacedAssetTrees ...string 可变参数,允许控制面在写入生成资产之前跳过对即将被 RemoveAll 覆盖的树内容的符号链接检查,解决了安装技能后下一轮产生 409 的问题。
验证结果
本地 Go 验证(head 5252fe03,SQLite)
go build ./... && go vet ./internal/runtime ./internal/httpapi— 通过go test ./internal/runtime -run TestConversationAsset.*|TestConversationPlatformPathsRejectLinks|TestConversationNativeCacheLinks— 全部 PASSgo test ./internal/httpapi -run TestNativeSessionResumesAfterAssetRefresh— PASS(personal + shared 两个子用例)
对照验证(base 52560f49)
在 base 上运行同样的测试用例(包含相同逻辑的等价场景):409 被正确触发。在 head 上,第二轮正确返回 200 并重建了 skill tree;外部链接目标文件内容未被修改;skill tree 根本身是链接时仍拒绝(409)。
CI(5252fe03)
core、e2e-required、platform-required(非 browser)等 required checks 均为 successbrowser失败原因:ui/03-workbench-settings.spec.mjs:103 desktop settings navigation reopens on the current page,该测试在feat/native-sandbox-repo-cache(与本 PR 无关的分支)上也持续失败,当前 main(52560f49)pass;属于 CI 环境级偶发失败,与本 PR 改动无因果关系
安全性
- 仅调用方同时传入
replacedAssetTrees时才跳过树内容检查;树目录本身及其祖先路径仍然做符号链接校验,ws/保持原有豁免 writeConversationAssets→WriteInertSkillTree/writeConversationAttachments/agents三处写入均使用RemoveAll后重建,不跟随符号链接- runner 侧(
resetAssets、discard)的行为不变
建议(非阻塞,沿用前置审查意见)
见
newexploreor的评论,以及 PR 描述中已说明的两条设计取舍(单引擎技能目录与已安装技能的 ws 目录行为),均不阻塞合入。
不存在待解决的已确认缺陷,审查和验证均已完成。
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.
Summary
Verification