Skip to content

ACP threads stay stuck running with "Provider session ... is not active." after provider re-sign-in #40724

Closed

Description

@ProfHercules

What happened

After starting Antigravity sign-in in provider settings while several Antigravity threads were actively running:

  • On one thread whose last agent action was requesting user input, the input popup never appeared and sending a message failed with an error about the provider session not being active.
  • All active Antigravity threads became stuck in the running state and failed on every message send with:
    Provider session provider-session:provider-instance:antigravity:thread:<thread-id>:<session-id> is not active.

Diagnosis

Releasing an active ACP provider session (ProviderSessionManager.releaseEntry) races with RunExecutionService's failure cleanup, causing AcpAdapterV2.interruptTurn to exit with Exit.Interrupted. RunExecutionService lets that interrupt escape without calling writeFinalRunEvents, stranding every in-flight run in status: "running" after its live session is gone.

Exact sequence in v0.1.11 (59651c1761, still present on main @ ad1b1f9ca4):

  1. Session teardown starts: Starting sign-in (provider.auth.start → AntigravityAuth.runSignIn, apps/server/src/provider/AntigravityAuth.ts:331-333) calls ProviderAuthService.stopSessions (apps/server/src/provider/ProviderAuthService.ts:99-155), which calls providerSessions.release({ providerSessionId, reason: "manual_shutdown", detail: "Provider sign-in changed." }) for every active session on that provider instance.
  2. Scope closes immediately after failing subscribers: ProviderSessionManager.releaseEntry (apps/server/src/orchestration-v2/ProviderSessionManager.ts:1361-1424) removes the live entry, calls failSubscribers (emitting ProviderAdapterEventStreamError with raisedByT3: true), and immediately starts closeScopeWithin(entry.scope, ...) — where entry.scope is AcpAdapterV2's sessionScope (packages/provider-acp/src/server/adapter.ts:2015). It then persists provider-session.updated (status: "stopped") and writeReleasedRuntimeRequestEvents (cancelling any pending user_input request — which is why the input popup vanished on <thread-1> right as it was opened).
  3. RunExecutionService calls interruptTurn during teardown: On each affected thread (~0.6–1.1 ms after closeScopeWithin starts), RunExecutionService's providerEventFiber (apps/server/src/orchestration-v2/RunExecutionService.ts:1976-2197) enters Effect.catchCauseIf((cause) => !Cause.hasInterruptsOnly(cause), ...) (:2018-2020). Before calling writeFinalRunEvents (:2131), lines :2082-2115 unconditionally invoke input.session.interruptTurn({ providerThread, providerTurnId, requestRuntimeRestart: true }) (even though raisedByT3 === true and T3 is already closing the session), with only:
    Effect.catchCauseIf(
      (interruptCause) => !Cause.hasInterruptsOnly(interruptCause),
      ...
    )
  4. AcpAdapterV2.interruptTurn exits Interrupted: AcpAdapterV2.interruptTurn (packages/provider-acp/src/server/adapter.ts:10007-10315) takes runtimeTransitionPermit, forks transitionFiber via Effect.forkIn(sessionScope, { startImmediately: true, uninterruptible: true }) (:10309), and joins it (restore(Fiber.join(transitionFiber)), :10311). Because sessionScope is already closed/closing, forkIn returns an immediately-interrupted fiber (never running its Effect.ensuring(runtimeTransitionPermit.release(1))), and Fiber.join exits in <1 ms with Exit.Interrupted (InterruptError: All fibers interrupted without error).
  5. Cleanup aborts before finalizing the run: Because RunExecutionService.ts:2093 only catches !Cause.hasInterruptsOnly(interruptCause), the adapter's closed-scope interrupt escapes both the inner and outer Effect.catchCauseIf handlers and kills providerEventFiber before writeFinalRunEvents (:2131) executes.
  6. Every affected thread is stranded: The runs, run attempts, and provider turns remain permanently running while their provider sessions are stopped and absent from ProviderSessionManager. Subsequent message sends route through Orchestrator.dispatchSteerIntoRun (apps/server/src/orchestration-v2/Orchestrator.ts:6252-6372) and fail at :6370 with Provider session <id> is not active..

Note: This happened 3-for-3 across every Antigravity thread that had an in-flight turn when sign-in was started, and both sides of the bug remain unchanged on main (ad1b1f9ca4). Fixing it cleanly likely needs both:

  • AcpAdapterV2.interruptTurn not leaking runtimeTransitionPermit or returning Exit.Interrupted to an uninterrupted caller when sessionScope is already closed or closes concurrently during the transition.
  • RunExecutionService not calling interruptTurn when raisedByT3 === true (the session is already being torn down by T3) and/or ensuring an adapter-originated interrupt cannot abort writeFinalRunEvents when the ingestion fiber itself was not interrupted.

Steps to reproduce

  1. Start one or more active runs on an ACP-backed provider (e.g., Antigravity) so at least one turn is in flight (optionally with one thread waiting on a pending user_input elicitation).
  2. Open Settings → Providers → Antigravity and start Sign in (provider.auth.start), which invokes ProviderAuthService.stopSessions → ProviderSessionManager.release(..., { reason: "manual_shutdown", detail: "Provider sign-in changed." }).
  3. Return to the previously running thread(s).
    • Observe that any pending user_input prompt has been cancelled and no popup is shown, yet the thread still appears running.
  4. Send a message on any of those threads.
    • Observe Provider session provider-session:provider-instance:antigravity:thread:<thread-id>:<session-id> is not active.

Version

0.1.11 (Desktop app with local server; commit 59651c1761; verified still present on main @ ad1b1f9ca4)

Environment

macOS 15.8.1 (darwin arm64, 24.6.0), Node v24.22.1, T3 Code Desktop 0.1.11 (local server), Antigravity provider (gemini-4-neon, runtimeMode: auto)

Evidence

# Server trace (UTC) — all 3 active Antigravity threads hit the same sequence 3-for-3
06:30:47.599Z ws.rpc.provider.auth.start exit=Success
# Session 1 (<thread-1>, also had pending user_input elicitation from 06:26:08.605Z)
06:30:47.642530Z ProviderSessionManager.removeLiveEntry exit=Success
06:30:47.642627Z ProviderSessionManager.failSubscribers exit=Success
06:30:47.642633Z ProviderSessionManager.closeScopeWithin started (finished 06:30:48.654Z, 1012ms)
06:30:47.643021Z AcpSessionRuntime.recordTermination exit=Success
06:30:47.643990Z AcpAdapterV2.interruptTurn exit=Interrupted (0.27ms) cause=InterruptError: All fibers interrupted without error
06:30:48.651477Z elicitation/create exit=Interrupted
06:30:48.675390Z ProviderSessionManager.writeReleasedRuntimeRequestEvents exit=Success

# Session 2 (<thread-2>)
06:30:48.678856Z ProviderSessionManager.removeLiveEntry exit=Success
06:30:48.678928Z ProviderSessionManager.failSubscribers exit=Success
06:30:48.678935Z ProviderSessionManager.closeScopeWithin started (finished 06:30:49.754Z, 1075ms)
06:30:48.679078Z AcpSessionRuntime.recordTermination exit=Success
06:30:48.679603Z AcpAdapterV2.interruptTurn exit=Interrupted (0.02ms) cause=InterruptError: All fibers interrupted without error

# Session 3 (<thread-3>)
06:30:49.769854Z ProviderSessionManager.removeLiveEntry exit=Success
06:30:49.769942Z ProviderSessionManager.failSubscribers exit=Success
06:30:49.769952Z ProviderSessionManager.closeScopeWithin started (finished 06:30:50.310Z, 540ms)
06:30:49.770075Z AcpSessionRuntime.recordTermination exit=Success
06:30:49.770785Z AcpAdapterV2.interruptTurn exit=Interrupted (0.06ms) cause=InterruptError: All fibers interrupted without error
06:30:50.324705Z ProviderAuthService.stopSessions exit=Success

# Orchestration events afterwards:
# All 3 threads recorded provider-session.updated (status: "stopped") at 06:30:48.757Z / 06:30:49.857Z / 06:30:50.412Z
# (<thread-1> also recorded runtime-request.updated status: "cancelled" at 06:30:48.770Z),
# with NO run.updated / run-attempt.updated / provider-turn.updated terminal events until manual Stop ~32 minutes later.
# Sending any message in the meantime failed with:
#   Provider session provider-session:provider-instance:antigravity:thread:<thread-id>:<session-id> is not active.

Related issues

Fix applied or workaround

Pressing Stop manually on each affected thread cleanly interrupted the stranded runs and unblocked sending new messages without restarting the server.

Filed by

Gemini 4 Neon (Antigravity harness in T3 Code) via t3 triage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    via-triageFiled through npx t3 triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions