Skip to content

fix(acp): stopping a queued continuation lets the thread switch providers - #40653

Closed
spoukyii wants to merge 2 commits into
pingdotgg:mainfrom
spoukyii:users/spoukyii/provider-switch-after-stop
Closed

spoukyii wants to merge 2 commits into
pingdotgg:mainfrom
spoukyii:users/spoukyii/provider-switch-after-stop

Conversation

@spoukyii

Copy link
Copy Markdown
Contributor

Problem

An Antigravity thread can stop accepting provider or model switches until the server restarts. Each send is refused with "The previous provider is still running background agents or commands, and switching would end them. Wait for them to finish, or press Stop, then send the message again." Pressing Stop does not clear it, and neither does the agy process exiting.

How I hit it: a background task delegated from an Antigravity thread finished while the account was at its usage limit. The ACP adapter offered a continuation run for the wake, and that run sat queued behind the limit ("Usage limit reached, retry manually"). I tried to switch the thread to a Claude instance and got the refusal. Stop cancelled the queued run (it ended cancelled with no startedAt), but every later switch was still refused (server trace: message.dispatch failures at 17:50:19, 17:50:22, 17:50:23, thread.stop at 17:51:08, and another failure at 17:52:21).

Expected: once the queued continuation is cancelled, nothing is owed, so the switch goes through.

Change

offerContinuationRun in packages/provider-acp/src/server/adapter.ts latches continuationRequested and keeps its wake buffer until the continuation run starts. hasPendingBackgroundWork reports both. A run cancelled while still queued never starts, and the ACP request had no onRunEndedWithoutStarting, so nothing released the latch. ProviderContinuationService already calls that hook when the dispatched run ends with startedAt === null, and the Claude and OpenCode adapters already pass it.

The ACP request now passes onRunEndedWithoutStarting. For the current generation it bumps the generation, clears continuationRequested, and drops the wake buffer and the offered wake reports, which is what a started continuation does when it drains them. Background tasks the agent still reports as running keep blocking the switch, as before.

This covers every ACP flavour with post-settle continuation (Antigravity, Grok, registry agents).

Scope

A small fix for an obvious leak in an existing contract: the ACP adapter was the one continuation offerer without the never-started hook. No issue filed. #36596 is related but separate. It makes Stop reach work only the adapter's probe sees, and it does not change the ACP adapter.

Verification

  • New test in AntigravityAdapterV2.test.ts, "leaves no background work when the continuation run ends without starting": a finished daemon wakes the thread, the continuation is dispatched, and hasPendingBackgroundWork is true. The test then ends the run without starting it and expects hasPendingBackgroundWork to be false. On main it fails with a cancelled queued continuation must release its wake: expected undefined to not equal undefined. With the fix it passes.
  • AntigravityAdapterV2.test.ts, AcpAdapterV2.test.ts, AcpRegistryAdapterV2.test.ts, the ProviderContinuationService tests and BackgroundWorkStop.integration.test.ts: 264 passed. packages/provider-grok: 86 passed, 9 skipped. provider-acp and server typecheck clean; vp fmt --check and vp lint clean on the changed files.
  • Not checked: the same flow end to end in a built app against a real agy hitting a usage limit. The test drives the adapter with the mock agent the other Antigravity wake tests use.

Bug: The previous provider is still running background agents or commands, and switching would end them.

Written with Claude Opus 5.5 in Claude Code, run from T3 Code.

…es no background work

Bug: The previous provider is still running background agents or commands, and switching would end them.
…ders

An ACP wake latched continuationRequested and kept its wake buffer until the
continuation run started. When Stop cancelled that run while it was still
queued, as it is behind a usage limit, nothing released the latch, so
hasPendingBackgroundWork stayed true and every provider switch or fresh
session was refused until the server restarted. The request now passes
onRunEndedWithoutStarting, as the Claude and OpenCode adapters do, and drops
the wake traffic the unstarted run would have drained.

Bug: The previous provider is still running background agents or commands, and switching would end them.
@github-actions

Copy link
Copy Markdown
Contributor

Closing: spoukyii already has 3 or more open PRs here, which is the limit for contributors who are not vouched.

Once one of them is merged or closed, open this again. See the open PR limit.

@github-actions github-actions Bot closed this Nov 22, 2026
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant