fix(server): delete temporary ACP health probe sessions#25395

open5
main
fix/issue-25382
opened8d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 5d ago

Problem

ACP Registry health checks create a real session to inspect the agent. With managed OpenCode V2 2.1.4, each uncached provider-status refresh left an untitled, zero-message session in OpenCode's history.

Change

Delete the probe's own session before tearing down the ACP process when the agent advertises session deletion. Cleanup is best effort and bounded to five seconds, so deletion errors do not change provider health.

Allow the existing session/delete RPC after ACP v1 negotiation. OpenCode 2.1.4 advertises and implements deletion on v1, but the client previously rejected it locally before sending the request.

Scope and approval

Fixes https://github.com/pingdotgg/t3code/issues/25382

Triaged bug via the automated issue flow. GitCafe: #25382.

Verification

  • Red first: probe cleanup cases failed because no delete request reached the agent; the v1 compatibility case failed with a local Method not found: session/delete. Recorded red results.
  • vp run check:changed: format, lint, both knip phases, generated GraphQL, typecheck of eight affected packages, and 41 tests in two files passed. The unrelated untracked app.json was excluded from changed-file selection without changing its content. Complete check output.
  • Real Linux web/server runtime with vp run dev --home-dir /tmp/t3-issue-25382-runtime --no-seed and managed OpenCode 2.1.4: provider status remains Available after refresh and two uncached startup probes. Both probes send successful deletion requests. All 13 baseline reproduction sessions and their message counts remain unchanged; the newly created probe session is absent. The preexisting conversation retains its two messages.
  • Runtime transcript, runtime driver, direct-wire driver. T3 runtime state was isolated; OpenCode used its default provider storage, inspected read-only for the comparisons.
  • Server-only change: visual fixture matrix is empty. No client rendering, wire schema, or platform-specific code changed. Cleanup success and failure are covered by subprocess tests, and advertised v1 deletion by an in-memory protocol test.

Implemented and reviewed with Claude Opus 5.5 and GPT-6.1-Sol through T3 Code's Claude and Codex harnesses.

Checks

22 successful · 6 skipped
All checks passed
d3983ee

Added 5 commits

  • fix(server): ACP health probe deletes its own session03486af
  • test(server): ACP health probe must delete its session3789cf6
  • fix(effect-acp): send session/delete to v1 agents4f8dd4e
  • test(effect-acp): v1 agents advertising session/delete must get the request6e11cb4
  • Merge remote-tracking branch 'origin/main' into fix/issue-25382d3983ee
Synced from GitHub

Approvability

Verdict: Approved at d3983ee

Macroscope's review found this PR approvable — This is a focused ACP health-probe cleanup fix: advertised session/delete support is now used for both v1 and v2 agents, with deletion bounded by a short timeout and ignored on failure. The remaining changes are test coverage and mock-agent support, with no product-default or static-analysis configuration changes.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB−7 B (−0.1%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.2 KiB−7 B (−0.6%)2.0 KiB✅
CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.0 KiB5.0 KiB+7 B (+0.1%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB+7 B (+0.6%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: 1ecb1a0 · PR result: d3983ee · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between 1ecb1a0f9346c7902e98d4362cee0ececd93962c and d3983ee410a844fc92a74adbf1713bc72f820d4a.

External image Files selected for processing: 6
  • apps/server/scripts/acp-mock-agent.ts
  • apps/server/src/provider/AcpRegistryProbe.test.ts
  • packages/effect-acp/src/client.test.ts
  • packages/effect-acp/src/client.ts
  • packages/provider-acp-registry/src/server/probe.ts
  • packages/provider-acp-registry/src/testing.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.

Walkthrough

The ACP client now sends session/delete for ACP v1. The ACP registry probe registers best-effort cleanup for its test session when deletion is advertised, with a five-second timeout. Tests cover successful and failed deletion outcomes.

Changes: ACP probe cleanup

Layer / File(s)Summary
ACP v1 session deletion
packages/effect-acp/src/client.ts, packages/effect-acp/src/client.test.ts
deleteSession now sends session/delete for ACP v1. A test verifies the request and successful response.
Probe session cleanup and validation
packages/provider-acp-registry/src/server/probe.ts, packages/provider-acp-registry/src/testing.ts, apps/server/scripts/acp-mock-agent.ts, apps/server/src/provider/AcpRegistryProbe.test.ts
The probe registers timed, best-effort deletion when the agent advertises the capability. The mock agent can return a deletion error. Tests check readiness, the advertised capability, and one deletion request for both deletion outcomes.

Priority: External image Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: maria-rcks, t3dotgg

Merge Risk: External image Minimal · up to d3983

The cleanup is ready to merge after normal checks. A rare timeout during startup could still leave an empty probe session.

Pre-merge checks: Passed 4
Check nameStatusExplanation
Description checkPassedThe description includes all required sections. It clearly states the problem, explains the cleanup and ACP v1 changes, links the tracked issue and approval context, and provides detailed verification…
Title checkPassedThe title clearly and concisely describes the main change: deleting temporary ACP health probe sessions on the server.
Linked Issues checkPassedIssue #25382 requires deletion of probe-created sessions when the agent advertises sessionCapabilities.delete, ignored cleanup failures, and support for session/delete after ACP v1 negotiation. `p…
Out of Scope Changes checkPassedAll changed files support issue #25382. The mock-agent failure switch enables cleanup-error testing. The testing re-export enables probe tests. The client change enables the required v1 deletion RPC. …
Full details: Description check

Explanation

The description includes all required sections. It clearly states the problem, explains the cleanup and ACP v1 changes, links the tracked issue and approval context, and provides detailed verification results.

Full details: Linked Issues check

Explanation

Issue #25382 requires deletion of probe-created sessions when the agent advertises sessionCapabilities.delete, ignored cleanup failures, and support for session/delete after ACP v1 negotiation. probeAcpRegistryConfiguration registers scoped deletion after session start, applies a five-second timeout, and ignores errors. AcpClient.agent.deleteSession now sends the RPC for v1. Tests cover successful and failed probe cleanup and a v1 agent that advertises deletion.

Full details: Out of Scope Changes check

Explanation

All changed files support issue #25382. The mock-agent failure switch enables cleanup-error testing. The testing re-export enables probe tests. The client change enables the required v1 deletion RPC. No unrelated product behavior or client, wire-schema, or platform changes appear in the reviewed diff.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.