Skip to content

修复 subagent 会话归属与后台任务隔离#4215

Closed
lifu963 wants to merge 10 commits into
esengine:main-v2from
lifu963:subagent-session-ownership
Closed

修复 subagent 会话归属与后台任务隔离#4215
lifu963 wants to merge 10 commits into
esengine:main-v2from
lifu963:subagent-session-ownership

Conversation

@lifu963

@lifu963 lifu963 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

背景

本 PR 修复 subagent transcript 与后台 jobs 的 session ownership 问题:Desktop 下 subagent 可能写到全局 session 目录,后台 job 也没有严格按 parent session 隔离,导致新建/删除/恢复会话时存在输出泄漏或 late writeback 风险。

变更内容

  • 统一主 session 与 SubagentStore 的 effective SessionDir,Desktop 下 subagent transcript 跟随 workspace session 目录;CLI 默认行为不变。
  • 为后台 jobs 增加 parent session 归属,并按当前 session 过滤 waitbash_outputkill_shell、status bar、完成摘要和 lifecycle notice。
  • clear / delete / trash session 时取消该 session 的后台 jobs,并防止后台 subagent 在取消后重新写回 active subagents/
  • Desktop restore 在目标 session cleanup 未完成时拒绝恢复,避免新 subagent transcript 被 destroyed checker 静默丢弃。
  • 同步 Controller.Run 路径的 job session 注入,使 headless / 直接调用路径与交互式 turn 一致。
  • 修复 destroy 与 job completion 之间的竞态,确保 destroyed session 不再产生 completion note / notice。

验证

  • gofmt -l .(root module,排除 desktop/)无输出
  • gofmt -l .desktop/ module)无输出
  • go vet ./...(root module / desktop/ module)
  • go test ./...(root module / desktop/ module)
  • git merge-tree --write-tree HEAD origin/main-v2 通过
  • macOS Desktop 真实验收:旧会话的后台 job 对新会话不可见、切回旧会话后可读;delete/trash 后 restore 不会恢复被取消 job,也没有输出泄漏。

lifu963 and others added 9 commits June 13, 2026 00:54
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>
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>
Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) skills Skill system (internal/skill, internal/tool) agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) and removed v2 Go rewrite (1.x) — main-v2 branch, active development labels Jun 12, 2026
Co-authored-by: Cursor <cursoragent@cursor.com>
esengine pushed a commit that referenced this pull request Jun 13, 2026
Integrates the session ownership foundation from PR #4215 and compatible state-routing fixes from PR #4073 and PR #3935. Contributor attribution and verification details are documented in the pull request body.
@SivanCola

Copy link
Copy Markdown
Collaborator

Superseded by #4250, which has now been merged. #4250 integrates this work with attribution in the PR body. Thank you again for the contribution.

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

Labels

agent Core agent loop (internal/agent, internal/control) config Configuration & setup (internal/config) desktop Wails desktop app (desktop/**) skills Skill system (internal/skill, internal/tool) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants