Skip to content

Release completed provider write payloads - #26208

Merged
nwparker merged 5 commits into
mainfrom
nwparker/perf-acp-write-payload-retirement
Oct 8, 2026
Merged

nwparker merged 5 commits into
mainfrom
nwparker/perf-acp-write-payload-retirement

Conversation

@nwparker

@nwparker nwparker commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​113 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​113
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

ELI5

An idle agent session can retain its last sent prompt. Completed and closed provider writers now release the stale reference immediately.

What Changed

Clear the saved drain-listener cleanup function after invoking it on completion and close. The current shared provider write queue owns that function; the protocol-specific wrapper remains a thin subclass. This preserves the newer active-write cancellation handling.

Why

Removing the stale reference at the existing completion boundary releases the payload without changing outgoing messages, queue ordering, backpressure or admission limits. It needs no new cache, timeout or prompt-size limit.

In seven alternating Node 24.20.0 process pairs, four actual ACP session runtimes sent generated 2 MiB text prompts and remained alive after successful replies. Median idle heap growth after GC fell from 8,669,808 to 275,376 bytes. All four removed drain closures remained alive before and none remained alive after. Every initialize, new-session, and prompt frame had identical byte lengths and SHA-256 hashes; native write buffers and drain listener counts were already zero in both versions. Four 256 KiB prompts also released about 1 MiB of excess heap. These are supported generated large-text fixtures, not captured ordinary prompts or evidence of improved typing latency.

Linked Issue

N/A — maintainer performance audit.

Visual Proof

N/A — completed write data ownership changes; no visual or interaction change.

Testing

The branch includes the test-only fixture correction in #26397: region-change scenarios now advance beyond the initial connection grace period, renew their existing control lease and refresh heartbeats. The corrected transport suites pass 16 tests, and 23 source-owned cutover checks preserve the minimum-age guard. No runtime rule is relaxed.

  • Automated lifetime controls cover completion, backpressure, queued writes and close with a late callback through the production JSON-RPC peer.
  • Refreshed shared queue, peer and retention tests: 22 passed.
  • Combined current-main validation: 654 main/renderer tests, 83 mobile tests and 78 performance contracts passed.
  • Full typechecks, desktop build and changed-code quality gate passed locally on macOS.
  • Retirement regressions fail against the current base implementation without cleanup and pass with the fix.
  • Hosted checks must complete on the refreshed PR head. Windows and live SSH execution were not repeated locally for this update.

Review

Clear the stale closure before admitting another write. Preserve active abort handlers, rejection order and the terminal error fence against late callbacks. Independent review found no negative user-facing trade-off.

Agent skill upstream boundary

  • Not applicable; no upstream skill source is copied or translated.

Notes

No wire format, execution-host routing, path or agent-status changes. Folder-workspace and remote callers retain the same lifecycle.

Checklist

  • Small, focused change; behavior, mechanism and approach explained.
  • Visual proof marked N/A with reason.
  • Correctness, security, performance and platform boundaries reviewed.
  • Relevant tests, typechecks, build, formatting and changed-code quality checks pass locally; hosted checks remain a merge gate.

@coderabbitai

coderabbitai Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a05dc828-2cea-4068-92e9-a81c5fb00f29
📥 Commits

Reviewing files that changed from the base of the PR and between 7039ae5 and 4ba931c.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5c24eeaf-26d9-420b-a691-7a5ce4229df7
📥 Commits

Reviewing files that changed from the base of the PR and between 1749eec and 7039ae5.

📒 Files selected for processing (1)
  • tests/e2e/relay-region-correction.unit.test.ts

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


📝 Walkthrough

Walkthrough

ProviderStdioWriteQueue now clears its stored drain-listener cleanup callback after closing or completing a write. New tests check drain-closure reachability during and after writes, with and without backpressure, including late completion after peer closure. The relay-region test setup now advances the clock, renews an active control lease, and records a heartbeat.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 7039a

The change releases completed write data while preserving close and cancellation behavior, and the relay test retains its intended lease and region-correction checks. No identified issue blocks merging, subject to normal hosted checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the primary change: releasing completed provider write payloads by clearing stale write references.
Description check ✅ Passed The description is complete and focused. It explains the change, motivation, validation, testing, scope, platform considerations, and maintainer exception for the missing linked issue.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
⚔️ Resolve merge conflicts 💡
  • Resolve merge conflict in branch nwparker/perf-acp-write-payload-retirement
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nwparker nwparker changed the title perf(acp): release the last sent prompt after write completion Release completed provider write payloads Oct 8, 2026
@nwparker
nwparker merged commit 10ac420 into main Oct 8, 2026
35 checks passed
@nwparker
nwparker deleted the nwparker/perf-acp-write-payload-retirement branch October 8, 2026 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant