Skip to content

ACP bridge leaves cursor-agent acp processes orphaned (PPID 1) when terminated by SIGTERM/SIGINT #5371

Closed

Description

@regenrek

Summary

When the ACP provider bridge worker is stopped by SIGTERM or SIGINT, it exits without stopping its ACP agent processes. On macOS we find cursor-agent acp processes re-parented to PID 1 that keep running indefinitely. Expected: the bridge stops all its agent processes before it exits, as it already does on onClose.

Versions and environment

  • bb 0.45.0-based build (desktop app + host daemon), macOS 26, two Macs
  • acp-cursor provider, cursor-agent 2026.10.01
  • Code path unchanged on main at 4b12265 and in 0.46.0 (4c87fdec7)

Steps to reproduce

  1. Use an ACP provider thread (we used acp-cursor) on a macOS host so the bridge has a live cursor-agent acp child.
  2. Terminate the bridge worker with SIGTERM (for example by restarting the host daemon LaunchAgent).
  3. ps -o pid,ppid,lstart,command -ax | grep 'cursor-agent acp'

We have not isolated which daemon shutdown path sends the signal live; the code path below is the part we are sure about.

Expected vs actual

Expected: no cursor-agent acp processes left after the bridge exits.
Actual (2026-10-11, before cleanup):
  kregenrek: cursor-agent acp, PPID 1, PID 47981, started Sun Oct 11 19:28:47 2026
  kregenrek: cursor-agent acp, PPID 1, PID 82824, started Sat Oct 10 23:11:11 2026
  devbook:   cursor-agent acp, PPID 1, PID 75708, started Sat Oct 10 17:24:05 2026

Evidence

In packages/provider-bridge-acp/src/bridge/bridge.ts on main:

  • stopAllSessions() only runs from onClose. The bridge does not set onSigterm/onSigint, although bridge-worker-entry.ts supports both. On SIGTERM the worker dies with Node's default handler and its agent children survive.
  • stopAllSessions() only reaches connections registered in sessionsByBbThreadId. Connections that are not sessions, for example the model discovery connection, are not stopped.
  • Nothing prevents a new connection from being spawned while shutdown is in progress.

Fix we run in our fork (4 files, +305/−12):

  • Track every AcpAgentConnection in a set, removed in its onExit.
  • Refuse new connections once shutdown has started.
  • One shutdownBridge() for onClose, onSigterm and onSigint: release all sessions and kill all tracked connections via Promise.allSettled, log failures to stderr, then exit.
  • Regression test in packages/agent-runtime/src/runtime.acp-topology.test.ts using the fake ACP agent (signal cleanup).

Happy to open this as a PR.

What you ruled out

Suggested priority and effort (optional)

Medium. Orphans accumulate per restart and keep their memory until killed by hand. Workaround: find and kill cursor-agent acp with PPID 1. Effort low, the fix is ready.

AGENT GENERATED. Written from a private BB thread, so there is no public link.

Activity

  1. added theissue type on Oct 12, 2026
  2. added
    providers
    host
    provider-acp
    confirmed-repro
    on Oct 12, 2026
  3. bb-slop-cop commented on Oct 12, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low. Labels: providers, host, provider-acp, confirmed-repro.
    • Reproduction report: REPRODUCED, high root-cause confidence. Two clean trusted-main checkouts show agents surviving worker exit.
    • Root cause: ACP omits signal-cleanup hooks; normal close only stops registered sessions, missing discovery agents. The fix tracks all connections, blocks new starts during shutdown, and awaits shared cleanup for EOF/SIGTERM/SIGINT.
    • Ready fix: PR #5374 — 256 changed text lines across two ACP files. Regression: five failures before, all six cases pass after; 700 relevant tests pass, four skipped; typecheck/lint pass.
    • Scope: Real worker with a deterministic Node ACP fixture on Linux; macOS/proprietary-provider details remain unverified. Eight unrelated Claude contract failures also occur on unchanged main.

    AGENT GENERATED

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reprohostprovider-acpproviders

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions