fix(acp): auto-approve detached full-access permission requests when continuation cannot attach #40673
Openluogao(GitHub profile, opens in a new tab)wants to merge 8 commits into
main fromrefs/pull/40673/headopened View on GitHubluogao(GitHub profile, opens in a new tab) linked this to fix #40032
tanstack-source added labelsbug
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
juliusmarminge added labelstakeover:in-progress
- @@ -5223,14 +5234,13 @@5234+ (yield* Ref.get(stoppedRunQuarantine)) ? "cancelled" : "unattached",5235+ );5236+ }5237+ });5238+ const clearIfCurrent = () => continuationPermit.withPermit(clearIfOwner);52235239 yield* continuationRequests.offer({52245240 threadId: route.threadId,52255241 providerThreadId: route.providerThreadId,52265242 driver,52275243 detail: null,52285244 ...(notification === null ? {} : { notification }),5229- clearIfCurrent: () =>5230- continuationPermit.withPermit(5231- Effect.gen(function* () {5232- if ((yield* Ref.get(continuationGeneration)) === generation) {5233- yield* Ref.set(continuationRequested, false);5234- }5235- }),5236- ),5245+ clearIfCurrent,5246+ onRunEndedWithoutStarting: clearIfCurrent,@@ -7349,16 +7372,16 @@73497372 policy: ProviderAdapter.ProviderAdapterV2RuntimePolicy,73507373 request: EffectAcpSchema.RequestPermissionRequest = params,73517374 ) => (flavor.permissionDisposition ?? acpPermissionDisposition)(policy, request);7375+ let turnState: "attached" | "unattached" | "cancelled" = "attached";73527376 if (73537377 (followsAgentWorkState && dispositionFor(latestRuntimePolicy) === "ask") ||73547378 (postSettleContinuationEnabled && flavor.wakeOnDetachedRequest)73557379 ) {7356- if (!(yield* awaitRequestTurn(handlerGeneration)))7380+ turnState = yield* awaitRequestTurn(handlerGeneration);7381+ if (turnState === "cancelled")73577382 return { outcome: { outcome: "cancelled" } } as const;73587383 }73597384 const admitted = yield* runRuntimeCallbackAtGeneration(73607385 handlerGeneration,73617386 Effect.gen(function* () {7362- const context = followsAgentWorkState7363- ? yield* Ref.get(activeTurn)7364- : yield* activeContext;7387+ if (yield* Ref.get(stoppedRunQuarantine)) {@@ -7393,3 +7422,4 @@73937422 : ({ outcome: { outcome: "selected", optionId } } as const),73947423 };73957424 }7425+ if (context === null && turnState === "unattached") {
Pushedd4cf948
- @@ -2837,4 +2837,10 @@28372837 flavor.extractSubagentSessionEvent !== undefined && !followsAgentWorkState28382838 ? undefined28392839 : flavor.extractSubagentUpdate?.(tool);2840- let turnAttached = yield* Deferred.make<boolean>();2840+ let turnAttached = yield* Deferred.make<"attached" | "unattached" | "cancelled">();2841+ const resolveTurnAttached = Effect.fnUntraced(function* (2842+ outcome: "attached" | "unattached" | "cancelled",2843+ ) {2844+ const waiting = turnAttached;2845+ turnAttached = yield* Deferred.make<"attached" | "unattached" | "cancelled">();2846+ yield* Deferred.succeed(waiting, outcome);
Pushedbbede84
github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase
github-actions[bot](GitHub profile, opens in a new tab) added labelsneeds-rebase
Sign in to join this conversation.
Note
Reviews paused#
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review.
Walkthrough
The continuation service now signals callbacks for all terminal run updates. The ACP adapter distinguishes attached, unattached, and cancelled requests, and applies those outcomes to user-input and permission admission. Antigravity tests cover detached permission requests across runtime modes and continuation states.
Changes: ACP Detached Request Handling
apps/server/src/orchestration-v2/ProviderContinuationService.ts,apps/server/src/orchestration-v2/ProviderContinuationService.test.ts,packages/provider-core/src/server/ProviderContinuationRequests.tspackages/provider-acp/src/server/adapter.tspackages/provider-acp/src/server/adapter.ts,apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.tsEstimated code review effort: 3 (Moderate) | ~25 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
Possibly related issues
Suggested reviewers:
juliusmarminge,saphidMerge Risk:
Low · up to
bbedeThe detached permission fallback for Antigravity full-access threads looks sound. A narrow Stop-timing race and a test-coverage gap remain; both are low impact and can be followed up after merge.
Pre-merge checks:
4
#40032] requires that, in full-access mode, a detached session/request_permission during a background-task wakeup (activeTurn === null) is auto-approved, or that a needed continuation attaches cleanl…Full details: Title check
Explanation
The title names the main change: detached full-access permission requests are auto-approved when a continuation cannot attach. It follows the conventional commit format and matches the ACP adapter, continuation, and test changes in the summary. The title is specific and does not use vague terms.
Full details: Description check
Explanation
The description follows the repository template. It has Problem, Change, Scope, and Verification sections. The Problem section gives the bug, the affected code paths, and the expected behavior. The Change section lists the edits in adapter.ts and the Antigravity tests. The Scope section links issue
#40032. The Verification section gives focused test commands, pass counts, a failing-first run, and states what could not be verified live. The description does not include the template's optional note about the agent model and harness in a required place, but it does name the harness at the end, so the template is met.Full details: Linked Issues check
Explanation
[
#40032] requires that, in full-access mode, a detached session/request_permission during a background-task wakeup (activeTurn === null) is auto-approved, or that a needed continuation attaches cleanly. The reviewed summaries describe these changes in packages/provider-acp/src/server/adapter.ts: (1) offerContinuationRun wires onRunEndedWithoutStarting alongside clearIfCurrent, so an unattached or dropped continuation clears continuationRequested and resolves turnAttached as "unattached" (or "cancelled" after Stop); (2) awaitRequestTurn returns "unattached" instead of hanging when no continuation can be offered; (3) handleRequestPermission reads Ref.get(activeTurn) instead of failing, and applies the allow/deny disposition when no turn is attached, so full-access (disposition allow) is approved. The follow-up commit also cancels detached ask requests cleanly instead of throwing. ProviderContinuationService.ts now calls onRunEndedWithoutStarting for any terminal run, which releases waiters when a dispatched run fails after starting. Explicit Stop still cancels; the issue does not require otherwise. The author reports AntigravityAdapterV2.test.ts 37/37 and three successful live macOS arm64 full-access wakeup flows. Limitation: the adapter.ts text diff is unavailable in this checkout (changed blobs missing), so the adapter behavior rests on the PR summary, AI change summaries, and author-reported tests. The atomic Stop/disposition check was not independently verified in source.Full details: Out of Scope Changes check
Explanation
The changes stay within detached ACP permission and turn-attachment handling. They touch packages/provider-acp/src/server/adapter.ts (turnAttached outcomes, awaitRequestTurn, cancelPendingRuntimeRequests, handleRequestPermission), the continuation release path in apps/server/src/orchestration-v2/ProviderContinuationService.ts (any terminal run now invokes onRunEndedWithoutStarting), its contract comment in packages/provider-core/src/server/ProviderContinuationRequests.ts, and matching regression tests in AntigravityAdapterV2.test.ts and ProviderContinuationService.test.ts. Each change connects to the detached-permission wakeup flow. The cancelDetachedRequests option was removed in the follow-up commit per the PR comments. Limitation: the adapter.ts source diff is unavailable, so the verdict for those hunks relies on the PR summary and AI-generated change summaries. The PR description still mentions cancelDetachedRequests, which is stale relative to the objectives; this does not add out-of-scope code.
Finishing Touches
Generate unit tests (beta)
3a236b09-ac98-43af-92a1-3324d9b6bac6Reviewing files that changed from the base of the PR and between d4cf9481844643926e7ff1d50ccac6b37a055d0e and bbede84f847741725ca2ca19892071e435e35836.
packages/provider-acp/src/server/adapter.tsIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.