Skip to content

ACP adapter: serve-side sessions are never deleted — sessions map has no close path (#4707 audit gap a) #8313

Closed

Description

@dezren39

Filed by the #4707 closing audit of design #4706 (task 12695, lane code-n, 2026-11-10). Evidence at origin/main 9b65fa2, bin/opencode-acp-adapter.mjs.

Gap

The adapter creates one serve session per ACP session/new (sessions.set at :627, via POST /api/session at :622) and never deletes any of them: there is no DELETE /api/session/:id call anywhere in the file, no ACP session-close handler, and nothing runs on stdin close / SIGTERM except process.exit (main, end of file).

The adapter-side sessions map (:237) dies with the adapter process — acpx launches a fresh adapter per gateway session — so adapter-side lifetime is process-lifetime and acceptable. The serve side is different: the server is the fleet's ONE standing shared opencode serve, so every ACP session ever created persists server-side after its adapter exits, for as long as the serve process lives, unless the serve expires idle sessions itself (no evidence in this repo that it does).

What to settle

  1. Verify from the pinned serve whether idle sessions expire server-side, and on what clock. If they do, record it on Phase 4 (audit) of #4706 — closing state-and-route inventory + contract statement for the OpenClaw ACP adapter #4707 and close this as a named exception.
  2. If they do not: delete serve sessions the adapter owns — on stdin close / SIGTERM, DELETE /api/session/:id for every id in the adapter's sessions map (best-effort, bounded time, never blocking exit), and disposition the crash case (adapter killed hard: sessions leak until serve restart — state whether that residual is accepted).

Design context: #4706 open question 2 named exactly this — it needed Phase 4 evidence before becoming work; this issue is that evidence landing.

Activity

  1. added
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    on Nov 10, 2026
  2. developing-today commented on Nov 10, 2026

    @developing-today
    Contributor
  3. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · triaged

    Triage (inline, this pass):

    • Work kind: small-fix (task/small-fix) — one file's session lifecycle plus a settle-first verification step the issue itself prescribes.
    • Priority: priority/normal — a verified resource leak on the fleet's one shared serve, default band.
    • Effort: effort/m — verify the pinned serve's idle-expiry behavior first; the fix (best-effort DELETE of owned sessions on stdin close / SIGTERM) is small, the crash-case disposition is a judgment call to record.
    • Kind: kind/bug applies (a leak against the Design: a prompt's state dies with the prompt — one server contract and one lifecycle for the OpenClaw ACP adapter #4706 lifecycle rules); app/id already present.

    Evidence (fresh, 2026-11-16):

    Issue #8313 stays open for task 20119.

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    priority/normalOrdinary priority (the default)
    effort/mMedium: expected under 1 day of work
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    and removed
    queue/claimedQueue worker lifecycle state
    work/assignedQueue worker lifecycle state
    on Nov 17, 2026
  5. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · parked on PR #11218 — no serve-side expiry (verified from the pin); adapter-side cleanup implemented

    • Agent: repo-worker-code (Muse lane code-a)
    • Session / ID: queue task 20119
    • Found via: atomic claim from the one fleet queue (stream repo-health-code-pilot), filter repo = code

    Step 1 — the pinned serve does NOT expire idle sessions. Verified in the fork source at the flake.lock pin (opencode = 34cb01197a2fa9f6fe75ac9f8e2a2ac3774bba53): the only inactivity mechanism, packages/core/src/location-activity.ts, interrupts inactive executions and evicts cached location service graphs — session records themselves are durable and are removed solely through the explicit DELETE /api/session/:sessionID route (packages/protocol/src/groups/session.ts, operationId session.remove). So the named-exception branch does not apply; nothing to record on #4707 as an expiry (the question it left open is answered: no expiry).

    Step 2 — implemented in PR #11218 (commit 792bcd4): stdin close and SIGTERM now share one shutdown path that issues DELETE /api/session/:id for every key of the adapter's sessions map — exactly the sessions this adapter created. Best-effort and bounded: per-delete abort timeouts against a 2s overall budget, failures swallowed, and a hard timer guarantees exit is never blocked on the serve. Tests: node --test bin/opencode-acp-adapter.test.mjs 24/24 pass, including two new tests (stdin close and SIGTERM each produce exactly one DELETE for the created session before exit 0; the stub serve gained the DELETE route).

    Crash-case residual — dispositioned: if the adapter is killed hard (SIGKILL, host death), no cleanup runs and its sessions persist on the serve until the serve restarts. Accepted: only the serve could reap those, it does not expire sessions (above), and the residual is inert records bounded by serve restarts.

    Remaining: merge PR #11218, then close this issue with evidence. Task 20119 is parked on the PR's CI.

  6. added
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    status/parkedDeliberately paused with a recorded resume condition
    on Nov 17, 2026
  7. dezren39 commented on Nov 17, 2026

    @dezren39
    MemberAuthor

    Re-verified — parked on PR #11218 merge (task 20119, lane code-d)

    The broker re-served task 20119 after lane code-c's park. Rather than redo settled work, I independently re-verified it:

    Nothing remains but the merge: task 20119 is re-parked on PR #11218 merging; close this issue with the PR's evidence once it lands.

  8. added a commit that references this issue on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)queue/parkedQueue task is parked (waiting on CI, time, or an event)status/parkedDeliberately paused with a recorded resume conditionstatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions