-
Notifications
You must be signed in to change notification settings - Fork 1.7k
refactor(agent): eliminate double-apply of session mode at ACP start #1892
Description
Problem
When a non-default session mode (e.g., acceptEdits, auto, dontAsk, plan) is configured, setSessionMode is called twice in succession during ACP session startup:
- Inside
AcpAgent.start()viaapplySessionMode()(L348-351 inacp/index.ts) - Immediately after
start()resolves viathis.agent.setMode(this.currentMode)inAcpAgentManager(L518-521)
This double-apply was already present for YOLO modes; after the applySessionMode extraction it now also applies to non-YOLO modes. The calls are functionally harmless (idempotent) but add unnecessary latency to session startup and produce duplicate perf log entries.
Suggested Fix
Option A (lower risk): Add a flag this.sessionModeApplied = true in start() so the manager can skip re-application.
Option B (cleaner): Remove mode application from inside start() and let the manager's post-start block be the single owner. Note: this changes error semantics for YOLO (manager logs a warning but does not throw).
Files
src/process/agent/acp/index.ts(L336-352, L406-424)src/process/task/AcpAgentManager.ts(L515-525)