Skip to content

fix(agent): reset planner session on tab switch to prevent cross-session contamination#4934

Closed
liaoyl830 wants to merge 1 commit into
esengine:main-v2from
liaoyl830:fix-4926-pe-contamination
Closed

fix(agent): reset planner session on tab switch to prevent cross-session contamination#4934
liaoyl830 wants to merge 1 commit into
esengine:main-v2from
liaoyl830:fix-4926-pe-contamination

Conversation

@liaoyl830

Copy link
Copy Markdown
Contributor

Summary

修复 #4926: Plan-Execute dual-model 跨会话计划污染

问题: 当使用双模型 Plan+Execute 模式时,同一项目下的多个标签页会发生跨会话污染。Tab A 的 Planner 输出可能被路由到 Tab B 的 Executor。

根因: 切换标签页时没有重置 planner session,导致 Coordinator 的 plannerSess 中的旧状态污染新的会话。

修复:Controller.ResetPlannerSession() 导出为公开方法,并在桌面层的每个标签页激活路径中调用:

  • SetActiveTab: 用户在标签页间切换
  • openTopicTabWithActivation: 复用现有标签页
  • CloseTab: 关闭标签页后切换到下一个

Changes

  • internal/control/controller.go - 导出 ResetPlannerSession() 方法
  • desktop/tabs.go - 在4个标签页激活点调用 ResetPlannerSession()
  • internal/control/controller_test.go - 添加测试验证

Verification

  • go test ./internal/agent/... passes
  • go test ./internal/control/... passes (包括新测试)
  • go vet ./... clean
  • gofmt -w . clean

Fixes #4926

Cache impact

Cache-impact: none — 仅添加了方法调用,不改变系统提示或缓存前缀。
Cache-guard: N/A

…ion contamination (esengine#4926)

When using dual-model Plan+Execute mode, switching between tabs could cause
Tab A's planner output to leak into Tab B's executor handoff. The planner
session history was not cleared when activating a different tab, allowing
stale plans from a previous conversation to contaminate the new active tab.

Fix: Make Controller.ResetPlannerSession() public and call it at every tab
activation path in the desktop layer:
- SetActiveTab: when user switches between tabs
- openTopicTabWithActivation: when reusing an existing tab (same session)
- CloseTab: when the active tab changes to the next tab after closing

This is a minimal, defensive fix (Solution B from the issue) that ensures
each tab's planner history stays scoped to that tab's conversation.

Test: Added TestResetPlannerSessionClearsPlannerHistory to verify the
public ResetPlannerSession method correctly clears planner context.
@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) agent Core agent loop (internal/agent, internal/control) labels Jun 20, 2026
@SivanCola

Copy link
Copy Markdown
Collaborator

Thanks @liaoyl830. I reviewed this tab-switch reset direction while consolidating the PE handoff work into #4938.

I did not adopt the production reset behavior because latest main-v2 passes the planner output directly through the active Coordinator rather than through a project-level handoff buffer, and resetting planner state during tab activation could race with in-flight planning. The #4926 isolation concern should be handled separately if it is still reproducible on the current base.

Your investigation and proposed fix are credited in #4938 under Repository Contributor Credits. Closing this PR in favor of the current integration path.

@SivanCola

Copy link
Copy Markdown
Collaborator

Integrated into #4942, which combines the related desktop sidebar/session runtime fixes on top of the latest main-v2.

I kept the relevant contribution from this PR credited in the #4942 body and commit co-author trailers. Please use #4942 as the integration path for this set of changes.

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) desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Plan-Execute dual-model: per-project handoff buffer not isolated by topicId, causes cross-session plan contamination

2 participants