Skip to content

[Bug]: Antigravity thread permanently fails with Internal error after localharness disconnect drops in-memory session #30594

Closed

Description

@JZongf

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. Start an Antigravity thread (gemini-4-argon) in T3 Code using the managed agy_acp_server.par (v1.4.5) runtime.
  2. Trigger a condition where the underlying localharness_external subprocess disconnects or closes its local WebSocket connection to agy_acp_server.par (for example, when a heavy background command is cancelled via manage_task(kill) during active output streaming).
  3. Send a follow-up prompt in the same thread:
    • On the first follow-up prompt, agy_acp_server.par detects the closed connection and attempts self._rebuild_session_agent(session_id).
    • Inside _rebuild_session_agent, await session_info.stack.aclose() invokes local_connection.disconnect(), which attempts to send session_end_request over the already-closed WebSocket, raising websockets.exceptions.ConnectionClosedOK.
    • agy_acp_server.par fails to rebuild the agent and drops session_id from its in-memory session dictionary, while the agy_acp_server.par process itself stays alive.
  4. Send any subsequent prompt in the thread.

Expected behavior

When AcpAdapterV2.startTurn receives an unrecoverable session error (AcpRequestError: Internal error / ValueError: Session not found: <session_id>) from a long-lived agy_acp_server.par process, T3 Code should invalidate/recycle that ACP runtime process (or re-issue session/resume against the persisted <session_id>.db conversation file) so the thread can automatically recover on the next turn.

Actual behavior

T3 Code keeps reusing the same alive agy_acp_server.par process whose in-memory session table no longer has <session_id>, causing every subsequent prompt on the thread to permanently fail with AcpRequestError: Internal error until agy_acp_server.par is manually killed.

Impact

Major degradation or frequent failure

Version or commit

0.1.7-nightly.20261103.4119

Environment

Linux x64 (Ubuntu), T3 Code Server 0.1.7-nightly.20261103.4119, managed Antigravity ACP runtime 1.4.5 (923923a0d7dc8073...), gemini-4-argon

Logs or stack traces

# T3 Code boot-service.log
WARN: orchestration-v2.acp-prompt-failed
  driver: 'antigravity',
  cause: 'AcpRequestError: Internal error\n' +
    '    at AcpRequestError.fromProtocolError (.../t3:185219:11)\n' +
    '    at AcpAdapterV2.startTurn (.../t3:202669:55)'

# agy_acp_server.par.INFO / ERROR
W1104 11:12:19.816289 server.py:5734] Agent connection closed for session <session_id>; rebuilding agent and retrying the turn once.
I1104 11:12:19.816335 agent.py:264] Stopping Agent session
E1104 11:12:19.828619 server.py:5866] Failed to rebuild agent for session <session_id>; connection unrecoverable
Traceback (most recent call last):
  File ".../acp_server/server.py", line 2174, in _rebuild_session_agent
    await session_info.stack.aclose()
  ...
  File ".../connections/local/local_connection.py", line 575, in disconnect
    await self._send_session_end_request()
  File ".../websockets/asyncio/connection.py", line 957, in send_context
    raise self.protocol.close_exc from original_exc
websockets.exceptions.ConnectionClosedOK: received 1000 (OK); then sent 1000 (OK)

The above exception was the direct cause of the following exception:
  File ".../acp_server/server.py", line 5739, in prompt
    await self._rebuild_session_agent(session_id)
  File ".../acp_server/server.py", line 2207, in _rebuild_session_agent
    raise RuntimeError(f"Failed to rebuild agent: {e}") from e
RuntimeError: Failed to rebuild agent: received 1000 (OK); then sent 1000 (OK)

E1104 11:13:23.219281 connection.py:237] Unhandled error while handling request method=session/prompt
Traceback (most recent call last):
  File ".../acp_server/server.py", line 5612, in prompt
    raise ValueError(f"Session not found: {session_id}")
ValueError: Session not found: <session_id>

Workaround

Manually kill the agy_acp_server.par process on the host (pkill -f agy_acp_server.par). On the next prompt, T3 Code spawns a fresh agy_acp_server.par process and resumes the session from the SQLite .db file on disk.

Activity

  1. juliusmarminge commented on Nov 19, 2026

    @juliusmarminge
    Member

    Fixed by #23654, now on main: After the reported local-harness disconnect and failed rebuild, sending another message now starts a fresh ACP process and resumes the saved conversation instead of repeatedly failing with Internal error.

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