You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ACP adapter: serve-side sessions are never deleted — sessions map has no close path (#4707 audit gap a) #8313
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).
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.
Expectation: done = triage verdict + labels recorded (this note), follow-on task 20119 queued, task 18634 completed as 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.
🤖 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.
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:
Settle spot-check (pinned serve): at the flake.lock pin 34cb01197a2fa9f6fe75ac9f8e2a2ac3774bba53 of developing-today-forks/opencode, packages/core/src/session.ts + packages/server contain no session expiry/reaper/TTL — "idle" there is execution state only; Session.remove is called solely by explicit client actions (app UI, CLI delete, opencode's own ACP deleteSession), and the pinned OpenAPI carries DELETE /api/session/{sessionID} (session.remove). Matches the PR fix(acp-adapter): delete owned serve sessions on shutdown (#8313) #11218 evidence.
Activity
developing-today commentedon Nov 10, 2026
CODE-2480
dezren39 commentedon Nov 17, 2026
🤖 Agent note · triaged
Triage (inline, this pass):
Evidence (fresh, 2026-11-16):
Issue #8313 stays open for task 20119.
dezren39 commentedon Nov 17, 2026
🤖 Agent note · parked on PR #11218 — no serve-side expiry (verified from the pin); adapter-side cleanup implemented
repo = codeStep 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 explicitDELETE /api/session/:sessionIDroute (packages/protocol/src/groups/session.ts, operationIdsession.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/:idfor every key of the adapter'ssessionsmap — 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.mjs24/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.
dezren39 commentedon Nov 17, 2026
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:
34cb01197a2fa9f6fe75ac9f8e2a2ac3774bba53of developing-today-forks/opencode,packages/core/src/session.ts+packages/servercontain no session expiry/reaper/TTL — "idle" there is execution state only;Session.removeis called solely by explicit client actions (app UI, CLI delete, opencode's own ACPdeleteSession), and the pinned OpenAPI carriesDELETE /api/session/{sessionID}(session.remove). Matches the PR fix(acp-adapter): delete owned serve sessions on shutdown (#8313) #11218 evidence.792bcd4dc0in the preserved worktree:node --test bin/opencode-acp-adapter.test.mjs— 24 pass, 0 fail, including "stdin close deletes the serve sessions the adapter created (ACP adapter: serve-side sessions are never deleted — sessions map has no close path (#4707 audit gap a) #8313)" and "SIGTERM deletes the serve sessions the adapter created (ACP adapter: serve-side sessions are never deleted — sessions map has no close path (#4707 audit gap a) #8313)".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.
Merge pull request #11218 from developing-today/queue/20119-8313-acp-…