fix(agent): 收紧 subagent fork 复用语义#4184
Merged
Merged
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
esengine
approved these changes
Jun 12, 2026
esengine
left a comment
Owner
There was a problem hiding this comment.
Thanks for this — it's a real hardening, not just a surface guard.
I traced the three load-bearing assumptions against main-v2 and they all hold:
- the subagent store lives at
<sessionDir>/subagents, sofilepath.Dir(s.dir)is exactly where branch metas resolve; LoadBranchMetadefaultsIDto the filename, so the id-consistency check is meaningful (it only rejects a meta whose declared id was renamed away from its file);ParentSessionisBranchID(SessionPath()), the same namespaceisAncestorSessionwalks.
Failing closed on missing / corrupt / cyclic / inconsistent lineage is the right call for a security fix — better to reject a legitimate ancestor-fork than to let a sibling or unrelated session's transcript leak in through a known sa_... ref. Test coverage across sibling / unrelated / unprovable / corrupt-meta cases is solid.
Merging.
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.
摘要
fork_from限制为只能复用当前会话或祖先会话链上的 subagent transcript,避免通过已知sa_...ref 复用兄弟分支或无关会话的上下文。fork_fromschema 描述,明确它是独立分叉而非同线程续接,并提示同一会话逻辑内应使用continue_from。验证
go test ./internal/agent ./internal/skillgofmt -l .(排除desktop/,无输出)git merge-tree --write-tree HEAD origin/main-v2git diff --name-status origin/main-v2...HEAD