Skip to content

refactor(agent): eliminate double-apply of session mode at ACP start #1892

@gobylor

Description

@gobylor

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:

  1. Inside AcpAgent.start() via applySessionMode() (L348-351 in acp/index.ts)
  2. Immediately after start() resolves via this.agent.setMode(this.currentMode) in AcpAgentManager (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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions