Skip to content

Scope ACP approval callbacks per session instead of swapping global terminal state #8081

@desmond0318

Description

@desmond0318

Summary

ACP prompt handling currently swaps tools.terminal_tool._approval_callback globally during a session run.

Verified current behavior

  • acp_adapter/server.py installs a per-session ACP approval callback into the process-global terminal callback before running the agent and restores it afterward.
  • The callback itself correctly fails closed for unknown/timeout/error outcomes (acp_adapter/permissions.py), but the installation model is still global.

Why this matters

  • Overlapping ACP sessions can interfere with each other.
  • Global callback swapping is hard to reason about and difficult to test under concurrency.
  • This is a design-hardening problem, not a simple one-line bugfix.

Scope

  • Make approval routing session-local or task-local instead of process-global.
  • Preserve existing single-session ACP behavior.
  • Add explicit concurrency coverage.

Non-goals

  • Do not change the approval UX or outcome mapping in the same change.
  • Do not bundle unrelated ACP/MCP work into this issue.

Acceptance criteria

  • Concurrent ACP sessions do not bleed approval callbacks across runs.
  • Single-session behavior remains compatible with existing ACP clients.
  • Regression tests cover at least two overlapping approval flows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/acpAgent Communication Protocol adaptersweeper:implemented-on-mainSweeper: behavior already present on current maintool/terminalTerminal execution and process managementtype/refactorCode restructuring, no behavior change

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions