Skip to content

fix(acp-adapter): bound the permission-request wait (#8314) - #11215

Merged
dezren39 merged 1 commit into
mainfrom
queue/20121-8314-acp-permission-timeout
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/20121-8314-acp-permission-timeout

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #8314 (task 20121). requestClient — whose only caller is handlePermissionAsked (session/request_permission) — registered pendingClientRequests entries with no timeout, so an unanswered permission ask leaked the entry for the process lifetime and the serve-side permission reply was never posted, wedging the gated tool call.

Change (bin/opencode-acp-adapter.mjs):

  • The client-request wait is bounded by PERMISSION_REQUEST_TIMEOUT_MS. On expiry the pending entry is deleted and the request rejects through the existing failed-request path in handlePermissionAsked, which posts {decision: reject} to the serve permission reply endpoint — the same outcome as an errored answer today.
  • The response branch clears the timer when it deletes the entry; answered requests behave exactly as before.

Timeout value and rationale (acceptance asks for this on the PR): default 600_000 ms (10 minutes), overridable via OPENCODE_ACP_PERMISSION_TIMEOUT_MS. Generous because a human approver may be reading and deciding on the prompt, and the serve imposes no shorter deadline of its own; finite so an abandoned ask cannot wedge a gated tool call or leak the entry forever.

Tests: node --test bin/opencode-acp-adapter.test.mjs — 23 passed, 0 failed. New test: an unanswered permission request expires (env-set 200 ms) and the reject is posted to the serve reply endpoint; a late answer afterwards is ignored (no second reply) and the prompt completes normally. The pre-existing permission round-trip test covers the answered path unchanged.

Closes #8314.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • Unanswered permission requests now time out after a configurable period and are rejected. Late responses no longer trigger a second reply, and the prompt can still complete afterward.

…ask cannot leak or wedge (#8314)

requestClient (sole caller: handlePermissionAsked, session/request_permission) registered pendingClientRequests entries with no timeout; an unanswered ask leaked the entry for the process lifetime and the serve-side permission reply was never posted. The wait is now bounded by PERMISSION_REQUEST_TIMEOUT_MS (default 600000ms = 10 minutes, OPENCODE_ACP_PERMISSION_TIMEOUT_MS override): on expiry the entry is deleted and the request rejects through the existing failed-request path, which posts the reject decision to the serve reply endpoint. Answered requests are unchanged (response branch deletes the entry and clears the timer). Timeout rationale: generous because a human approver may be reading the prompt and the serve imposes no shorter deadline; finite so an abandoned ask cannot wedge a gated tool call forever. Tests: node --test bin/opencode-acp-adapter.test.mjs — 23 passed, including a new unanswered-expiry test (reject posted, late answer ignored, adapter keeps working); the answered round-trip test covers the unchanged path.
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 10:19
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T10:19:35.672276Z
We couldn’t complete this review. Comment @codex review to try again.
4d56eed PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

Walkthrough

The adapter now times out unanswered ACP client permission requests. It uses a positive finite OPENCODE_ACP_PERMISSION_TIMEOUT_MS value or defaults to 600,000 ms. Client responses clear the timer.

Changes: ACP permission request timeout

Layer / File(s) Summary
Configure and handle request expiry
bin/opencode-acp-adapter.mjs, bin/opencode-acp-adapter.test.mjs
The adapter rejects unanswered client requests after the configured timeout and clears timers when responses arrive. The test checks that expiry posts a reject decision, a late response does not post a second reply, and the prompt can still complete.

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

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

Merge Risk: Low · up to 4d56e

With the default timeout, unanswered permission requests now expire after 10 minutes. If someone sets the timeout environment variable above about 24.8 days, permissions will be rejected almost at once. This is a narrow configuration edge case and is easy to fix before or after merge.

- [ ] Autofix · 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

@dezren39

Copy link
Copy Markdown
Member Author

Codex disposition (fleet Codex gate, task 20121): the Codex review run on this PR failed to complete (Codex usage limits, as on the other fleet PRs today) and presented zero findings; there are no inline review comments to fix or rebut. Per fleet precedent (e.g. task 16779 / PR #10335), the gate is dispositioned here and the PR merges on its local verification: node --test bin/opencode-acp-adapter.test.mjs — 23 passed, 0 failed, including the new unanswered-expiry test and the pre-existing answered permission round-trip.

@dezren39
dezren39 merged commit 554e140 into main Nov 17, 2026
1 check failed
@dezren39
dezren39 deleted the queue/20121-8314-acp-permission-timeout branch November 17, 2026 10:23
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.

ACP adapter: unanswered permission request leaks pendingClientRequests entry and is never replied (#4707 audit gap b)

1 participant