Skip to content

[Bug]: ACP startTurn misses recoverLostNativeSession when session/load fails with AcpTransportError #46045

Done

Description

@imetn

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Open an existing thread backed by an ACP provider (observed with Antigravity ACP 1.5.20, though this affects any ACP provider using AcpAdapterV2).
  2. Put the thread in a state where the server still treats it as loaded (so the next user message enters AcpAdapterV2.startTurn instead of resumeThread), while the underlying ACP runtime needs to reactivate the native session via activateSession (session/load / session/resume)—for example, after an ACP runtime restart/teardown.
  3. Cause activateSession (session/load) to fail at the transport layer (AcpTransportError) rather than returning a JSON-RPC error (AcpRequestError).
    • In real usage, this happened on a long-running iOS thread whose native history contained 16–26.7 MiB xcodebuild step outputs; during session/load, antigravityAuthSupport.splitStdoutLines rejected the oversized line with AcpTransportError (covered separately by fix(antigravity): stream large stdout protocol lines instead of failing at 16 MiB #42150). Any ACP child-process crash or transport disconnect during activateSession hits the same path.
  4. Send a follow-up message (Turn N), then send another message right after it fails (Turn N+1).

Expected behavior

Because activateSession (session/load / session/resume) failed before any session/prompt was sent, ProviderTurnStartService should treat the failure identically to a failed resumeThread and immediately invoke recoverLostNativeSession to start a fresh native session with context handoff on Turn N—instead of surfacing a ProviderAdapterTurnStartError to the user.

Actual behavior

  • Turn N (startTurn path): Fails immediately and surfaces Provider error to the user without triggering automatic recovery.
    • packages/provider-acp/src/server/adapter.ts (startTurn, around line 10828 on main @ 32158b76a3) wraps the activateSession(...) failure in ProviderAdapterTurnStartError whose cause is AcpTransportError (which does not carry a JSON-RPC method: "session/load" field).
    • apps/server/src/orchestration-v2/ProviderTurnStartService.ts (lines 288–290 on main @ 32158b76a3) defines nativeSessionLoadFailed as:
      const nativeSessionLoadFailed = (error: unknown): boolean =>
        (isAcpRequestError(error) && NATIVE_SESSION_LOAD_METHODS.has(error.method)) ||
        (Predicate.hasProperty(error, "cause") && nativeSessionLoadFailed(error.cause));
    • Because error.cause is AcpTransportError rather than AcpRequestError, nativeSessionLoadFailed(error) returns false and recoverLostNativeSession (lines 2618–2639) is skipped.
  • Turn N+1 (resumeThread path): The very next user message enters AcpAdapterV2.resumeThread, hits the exact same AcpTransportError during session/load, and does automatically trigger Recovering provider context in a fresh native session, succeeding cleanly.

Impact

Minor bug or occasional failure

Version or commit

main @ 32158b7

Environment

macOS 26.6.2 (Apple Silicon), T3 Code Desktop/Server, Antigravity CLI 1.5.20 (ACP, Gemini 4 Neon)

Logs or stack traces

# Turn N (11:07:42Z – 11:07:49Z): startTurn path -> fails without auto-recovery
[11:07:49Z] antigravityAuthSupport.splitStdoutLines (Failure)
  AcpTransportError: ACP transport operation failed: Antigravity sent a protocol line that is too large.

[11:07:48Z] session/load (Failure)
  ~effect/rpc/RpcClientError: RpcClientDefect: ACP protocol terminated.

[11:07:42Z] AcpAdapterV2.startTurn (Failure, durationMs=6629.27)
  ProviderAdapterTurnStartError: Failed to start run run:thread:<thread-id>:ordinal:118 on antigravity provider thread <provider-thread-id>.

[11:07:49Z] RunExecutionService.startRootRun (ERROR)
  "orchestration V2 provider turn start failed"
  {
    "runId": "run:thread:<thread-id>:ordinal:118",
    "cause": {
      "_tag": "Fail",
      "error": {
        "_tag": "ProviderAdapterTurnStartError",
        "driver": "antigravity",
        "threadId": "<thread-id>",
        "providerThreadId": "<provider-thread-id>",
        "runId": "run:thread:<thread-id>:ordinal:118",
        "cause": {
          "_tag": "AcpTransportError",
          "detail": "Antigravity sent a protocol line that is too large."
        }
      }
    }
  }

# Turn N+1 (11:09:42Z – 11:09:46Z): resumeThread path -> exact same error, auto-recovers
[11:09:46Z] antigravityAuthSupport.splitStdoutLines (Failure)
  AcpTransportError: ACP transport operation failed: Antigravity sent a protocol line that is too large.

[11:09:45Z] session/load (Failure)
  ~effect/rpc/RpcClientError: RpcClientDefect: ACP protocol terminated.

[11:09:42Z] AcpAdapterV2.resumeThread (Failure, durationMs=3348.06)
  ProviderAdapterResumeThreadError: Failed to resume antigravity provider thread <provider-thread-id>.
  [cause]: AcpTransportError: ACP transport operation failed: Antigravity sent a protocol line that is too large.

[11:09:42Z] orchestrationV2.providerTurnStart.start (WARN)
  "Recovering provider context in a fresh native session"
  {
    "driver": "antigravity",
    "providerThreadId": "<provider-thread-id>",
    "runId": "run:thread:<thread-id>:ordinal:119"
  }

Workaround

Sending another message on the same thread forces the next turn onto the resumeThread path, which catches the transport failure and triggers fresh-session recovery.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions