[Bug]: Antigravity ACP turns fail with transient UNAUTHENTICATED (code 401) around hourly OAuth token refresh
Before submitting
- [x] I searched existing issues and did not find a duplicate.
- [x] I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Configure the Antigravity provider in T3 Code using
oauth-personal(Google account sign-in) withagy acp(Antigravity CLI1.5.11–1.5.14). - Start one or more long-running Antigravity threads (or delegated subagent tasks) whose active
session/promptturn spans across the 1-hour Google OAuthaccess_tokenexpiry boundary. - Wait until
agy acphits the hourly OAuth token refresh (browser.go:265] token refreshed, new expiry=...) while the turn is still in flight.
Expected behavior
Long-running Antigravity turns should continue across the hourly OAuth token refresh without aborting.
Even while the underlying bug remains in agy upstream, when an already-authenticated Antigravity ACP session returns a transient UNAUTHENTICATED (code 401) around token refresh (where antigravity-oauth-token on disk has already been refreshed and the user is still signed in), T3 Code should ideally detect it as a transient refresh failure and recycle/retry the turn once instead of aborting the run with an auth error that looks like a sign-out.
Actual behavior
The active turn aborts with:
⚠ UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
(And delegated subagents fail with Antigravity stopped this turn because of an error.)
Observed across 17 failures in 16 separate acp-server-*.log files over several days (across Antigravity CLI 1.5.11–1.5.14), 100% of them follow the exact same pattern:
- The session started with a valid OAuth token from
<profile>/antigravity-acp/antigravity-oauth-token(AGY_ACP_FORCE_FILE_STORAGE=1). - A single
session/promptturn ran across the 1-hour expiry mark. browser.go:265successfully refreshed the token and persisted the new expiry (+1h), and subsequent background RPCs (fetchAvailableModels,loadCodeAssist) in the sameagy acpprocess succeeded with the new token.- Seconds (or minutes) later, the already-running
agent executorgoroutine failed withUNAUTHENTICATED (code 401). - When running 3–5 concurrent Antigravity threads in T3 Code, multiple threads hit 401 together at every hourly boundary (e.g.,
17:27,18:28,19:29,20:29), which feels like frequent forced logouts. - The user is not actually signed out: simply sending another message (which starts a new turn / restarts
agy acp) immediately succeeds using the already-refreshedantigravity-oauth-tokenwithout any re-login.
Note: This matches the same upstream agy hourly token-refresh bug reported in getpaseo/paseo#6487 (originally filed against agy 1.3.2 stream-json and later closed when Paseo migrated to agy acp in #10193 without testing credential refresh). Our logs confirm it still reproduces on agy acp up through 1.5.14.
Impact
Major degradation or frequent failure
Version or commit
T3 Code (Beta) 0.1.11
Environment
macOS 27.2 (Build 26B123), T3 Code (Beta) Desktop 0.1.11, Antigravity CLI 1.5.14 (also observed on 1.5.11–1.5.13), auth method oauth-personal (agy acp --gemini-dir ... --app-data-dir antigravity-acp, AGY_ACP_FORCE_FILE_STORAGE=1).
Logs or stack traces
# Example 1: acp-server-20261121_193835-1708.log (agy 1.5.14)
I1121 19:38:35.658425 203 keyring.go:64] keyringAuth: loaded token, expiry=2026-11-21 20:29:19.498064 +0800 CST expired=false
I1121 19:38:35.658459 10 server_oauth.go:226] OAuth: authenticated successfully as <redacted>
I1121 19:42:56.916254 1346 server.go:213] ACP Request received: session/prompt
...
I1121 20:28:15.534040 1313 http_helpers.go:760] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:streamGenerateContent?alt=sse
I1121 20:29:36.136962 9541 browser.go:265] token refreshed, new expiry=2026-11-21 21:29:35.136829 +0800 CST m=+6659.569719667
I1121 20:29:37.412201 9542 http_helpers.go:760] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels
I1121 20:29:38.570535 9543 http_helpers.go:760] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:loadCodeAssist
E1121 20:29:46.966708 1313 errorreport.go:282] agent executor error: generating and executing: UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
# Example 2: acp-server-20261120_204314-6063.log (single process, no concurrent refresh)
I1120 20:43:15.032797 196 keyring.go:64] keyringAuth: loaded token, expiry=2026-11-20 21:43:01.977122 +0800 CST expired=false
...
I1120 21:43:16.865436 8034 browser.go:265] token refreshed, new expiry=2026-11-20 22:43:15.865382 +0800 CST m=+7200.920453542
I1120 21:46:15.934944 8261 http_helpers.go:771] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:loadCodeAssist
I1120 21:46:16.365362 8260 http_helpers.go:771] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels
E1120 21:50:19.023864 593 errorreport.go:285] agent executor error: generating and executing: UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
I1120 21:52:16.062115 8731 http_helpers.go:771] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:loadCodeAssist
I1120 21:52:16.223788 8730 http_helpers.go:771] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels
Workaround
Sending another message (e.g., "continue") in the thread restarts/resumes the session using the already-refreshed antigravity-oauth-token without needing to sign in again. Using an API key (gemini-api-key) or Vertex AI (agent-platform) also avoids the hourly OAuth refresh.
Update — found the matching upstream root-cause issue in Antigravity CLI:
- google-antigravity/antigravity-cli#1091 (
Agent requests fail with UNAUTHENTICATED 401 after a successful OAuth token refresh.), where multiple users also confirm this still reproduces onagy acp1.5.13–1.5.14.
While waiting on Google to fix it upstream in agy, there looks like a clean mitigation point on the T3 Code side in src/provider/acp/AntigravityTurnOutcome.ts:
watchAntigravityPromptOutcomecurrently matches upstream errors withAPI_ERROR = /Error (\d{3}), Message: (.+?), Status: ([A-Z_]+)/s.- Because
agy acpwritesUNAUTHENTICATED (code 401): ...instead,apiErrorevaluates tonulland falls back to the generic non-retryable failure ("Antigravity stopped this turn because of an error.",retryable: false). - If
AntigravityTurnOutcome.tsparsesUNAUTHENTICATED (code 401)and checks that<profile>/antigravity-acp/antigravity-oauth-tokenstill exists with a valid/fresh expiry (distinguishing this transient refresh bug from an actual sign-out), T3 Code could treat it as retryable and recycle/retry the ACP turn once automatically before surfacing a failure.
Adding fresh evidence from 0.1.12-nightly.20261121.5064 (1a9a858d), including two important details for any T3-side mitigation:
Environment
- OS: macOS 27.0.1 (Build 26A434, arm64)
- T3 Code: Desktop Nightly
0.1.12-nightly.20261121.5064(1a9a858d, local server) - Antigravity CLI: Managed
1.5.13(oauth-personal, 2 Google accounts,gemini-4-neonwiththought_level: xhigh)
Observed pattern (6 failures across 338 acp-server-*.log files / 142 token refreshes)
All 6 UNAUTHENTICATED (code 401) failures landed 2.8s–113s past the hourly OAuth access-token expiry while an in-flight model call spanned the boundary (including 3 consecutive hourly boundaries on the same resumed delegated thread):
| # | Account | Token expiry (UTC+8) | Last tool confirmation before failure | browser.go:265 refresh |
401 timestamp | Delta from expiry |
|---|---|---|---|---|---|---|
| 1 | Account A | 00:28:24 |
00:28:10 (context summarization) |
Not finished before 401 (context canceled on SIGTERM) |
00:28:46 |
+22s |
| 2 | Account A | 12:54:28 |
12:53:45 |
12:54:27 (-1.3s, succeeded) |
12:55:04 |
+36s |
| 3 | Account B | 14:56:43 |
14:53:49 |
14:56:45 (+2s, succeeded) |
14:58:36 |
+113s |
| 4 | Account A | 15:33:59 |
15:32:08 |
Not finished before 401 (context canceled on SIGTERM) |
15:34:01 |
+2.8s |
| 5 | Account A | 16:34:40 |
16:32:45 |
16:35:00 (+20s, succeeded; fetchAvailableModels & loadCodeAssist then succeeded) |
16:35:11 |
+31s |
| 6 | Account A | 17:34:59 |
17:34:00 |
17:35:09 (+10.8s, succeeded) |
17:35:48 |
+49s |
| Control | Account A | 18:35:08 |
Previous streamGenerateContent ended at 18:34:50 (-18s); next call started at 18:35:25 (+17s) |
18:35:26 on same goroutine (9417), request succeeded at 18:35:27 |
(none) | — |
In every failure, neither account was signed out; sending "continue" to the same thread resumed cleanly with no re-login.
Relevant update for T3-side mitigation (on 1a9a858d)
STATUS_ERRORparsing andresumeWith: "continue"already exist onmain(from PR#39869for mid-turn404s):- In
apps/server/src/provider/acp/AntigravityTurnOutcome.ts,STATUS_ERRORalready parsesUNAUTHENTICATED (code 401): Request had invalid authentication credentials.... - However, lines 180–193 only mark
429,transientNotFound(404 && step?.reachedModel === true), and>= 500asretryable, and only setresumeWith: "continue"fortransientNotFound. - As a result,
packages/provider-acp/src/server/adapter.tssetsruntimeRestartRequired = true, sendsSIGTERMtoagy acp, and fails the turn/subagent.
- In
- Don't gate auto-retry solely on
antigravity-oauth-tokenalready having a fresh expiry on disk:- In failures #1 and #4 (
00:28:46and15:34:01), the 401 arrived beforebrowser.gocompleted its refresh, and T3'sSIGTERMcanceled the in-flight refresh (browser.go:258] token refresh failed: Post "https://oauth2.googleapis.com/token": context canceled). - Checking
step?.reachedModel === true(matchingtransientNotFound)—or verifying that anoauth-personaltoken file exists rather than requiring an already-fresh expiry—and recycling the runtime before resuming once with"continue"would cover both pre-refresh and post-refresh 401s.
- In failures #1 and #4 (
Redacted log excerpts (pre-refresh 401 vs. post-refresh 401)
# Failure #4 (pre-refresh 401 — refresh canceled when T3 terminates agy acp)
I1122 14:59:42.844008 173 keyring.go:64] keyringAuth: loaded token, expiry=2026-11-22 15:33:59.035326 +0800 CST expired=false
I1122 14:59:44.744391 471 server.go:213] ACP Request received: session/prompt
I1122 15:32:08.706651 8953 server.go:2821] Tool confirmation for conversation <conversation-id> step 136 (type=*gemini_coder_go_proto.Step_Generic approved=true)
E1122 15:34:01.851252 784 errorreport.go:285] agent executor error: generating and executing: UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
I1122 15:34:01.893453 42 serve.go:68] Received signal terminated, shutting down
W1122 15:34:01.983944 8927 browser.go:258] token refresh failed: Post "https://oauth2.googleapis.com/token": context canceled
# Failure #5 (post-refresh 401 — same process already refreshed and succeeded on other RPCs)
I1122 15:34:59.043879 198 keyring.go:64] keyringAuth: loaded token, expiry=2026-11-22 16:34:40.490718 +0800 CST expired=false
I1122 15:35:01.109578 296 server.go:213] ACP Request received: session/prompt
I1122 16:32:45.437795 10418 server.go:2821] Tool confirmation for conversation <conversation-id> step 261 (type=*gemini_coder_go_proto.Step_Generic approved=true)
I1122 16:35:00.092488 10596 browser.go:265] token refreshed, new expiry=2026-11-22 17:34:59.092466 +0800 CST m=+7200.144616835
I1122 16:35:00.839996 10597 http_helpers.go:771] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels Trace: 0xbc8e4126e193d601
I1122 16:35:00.990395 10598 http_helpers.go:771] URL: https://daily-cloudcode-pa.googleapis.com/v1internal:loadCodeAssist Trace: 0xde376d728f7dd23
E1122 16:35:11.680121 883 errorreport.go:285] agent executor error: generating and executing: UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Written by Gemini 4 Neon (Antigravity) in T3 Code.
I hit the same mid-turn 401 on November 23, 2026 with Gemini 4 Neon via Antigravity on macOS 15.7.9 (arm64). The installed T3 Code build is Nightly 0.1.12-nightly.20261122.5111, and the local agy --version reports 1.5.14.
- An earlier turn in the same thread surfaced the 401. Sending “keep working” then completed an Antigravity turn.
- A subsequent turn returned intermediate results and dispatched a Codex subtask before the Antigravity parent turn failed. The parent started at 01:52:47 UTC and failed at 02:24:09 UTC, about 31 minutes later.
The thread showed:
⚠ UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
I can confirm the message and turn timing from the thread history. I haven’t verified the token’s expiry or refresh timestamp for this run.
Confirming the same issue also reproduces on Linux x86_64 with T3 Code 0.1.11 + Antigravity ACP Server 1.5.14 (oauth-personal, file-based token storage, Gemini 4 Neon).
Additional Repro Observations (Linux x86_64)
We hit 3 occurrences across 2 days (including 2 concurrent threads failing together at the same hourly expiry mark 14:31:39):
- Process A (2026-11-23): token expiry
14:31:39.044→ tool confirmed at14:31:25.549(13.5s before expiry) →browser.go:265refreshed at14:31:35.307(new expiry15:31:34) →agent executorfailed withUNAUTHENTICATED (code 401)at14:32:06.434→ same process succeeded onfetchAvailableModels/loadCodeAssistat14:33:39without re-login. - Process B (2026-11-23, concurrent): loaded the same
14:31:39.044token → tool confirmed at14:31:14.651(24.4s before expiry) →UNAUTHENTICATED (code 401)at14:31:42.700→ refreshed at14:31:45.646. - Process C (2026-11-22): token expiry
02:43:18.308→ tool confirmed at02:43:00.675(17.6s before expiry) → refreshed at02:43:13.253→UNAUTHENTICATED (code 401)at02:43:22.230.
Also added these redacted Linux logs to the upstream Antigravity issue: google-antigravity/antigravity-cli#1091.
Additional Finding on the T3 Code Side (AntigravityTurnOutcome.ts)
In T3 Code 0.1.11, src/provider/acp/AntigravityTurnOutcome.ts currently parses API errors with:
API_ERROR = /Error (\d{3}), Message: (.+?), Status: ([A-Z_]+)/s;
Because Antigravity ACP emits:
UNAUTHENTICATED (code 401): Request had invalid authentication credentials...
API_ERROR.exec(text) returns null, so turnFailure() falls back to a generic provider_error ("Antigravity stopped this turn because of an error.") without extracting code: "UNAUTHENTICATED" / HTTP 401 or marking it retryable, and leaves any already-queued follow-up message held instead of recovering.
Recognizing UNAUTHENTICATED (code 401) in AntigravityTurnOutcome.ts (and optionally auto-retrying once when the on-disk antigravity-oauth-token is still valid / already refreshed) would cleanly mitigate the upstream hourly-refresh 401 while google-antigravity/antigravity-cli#1091 is open.
Confirming this also reproduces reliably on Windows 11 (10.0.26300.0) with T3 Code 0.1.11 and Antigravity CLI/ACP 1.5.13 (oauth-personal, gemini-4-neon).
Windows 11 Repro Timeline (5 occurrences across 2 days)
In all 5 occurrences, browser.go:265 refreshed the OAuth token successfully, and then agent executor failed with UNAUTHENTICATED (code 401) 13–68 seconds after the refresh:
| Date (UTC+7) | Token refreshed (browser.go:265) |
New expiry | UNAUTHENTICATED (code 401) (errorreport.go:285) |
Delay after refresh |
|---|---|---|---|---|
| 2026-11-24 | 06:04:06.951 |
07:04:05 |
06:05:14.316 |
+67s |
| 2026-11-24 | 07:04:11.209 |
08:04:10 |
07:04:41.429 |
+30s |
| 2026-11-24 | 08:04:49.959 |
09:04:48 |
08:05:57.573 |
+68s |
| 2026-11-25 | 06:08:26.764 |
07:08:25 |
06:08:40.237 |
+13s |
| 2026-11-25 | 07:09:28.953 |
08:09:27 |
07:10:26.704 |
+58s |
Sending Resume in the thread afterward immediately continued using the refreshed token without re-authenticating.
Redacted Windows acp-server log excerpts (2026-11-25)
# Occurrence 4
I1125 05:07:46.151467 212 keyring.go:64] keyringAuth: loaded token, expiry=2026-11-24 10:05:30.0312126 +0700 +07 expired=true
I1125 05:07:51.608838 212 browser.go:265] token refreshed, new expiry=2026-11-25 06:07:50.6088383 +0700 +07
I1125 06:08:26.764510 12453 browser.go:265] token refreshed, new expiry=2026-11-25 07:08:25.7645103 +0700 +07
E1125 06:08:40.237719 10271 errorreport.go:285] agent executor error: generating and executing: UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
# Occurrence 5
I1125 06:09:25.221529 197 keyring.go:64] keyringAuth: loaded token, expiry=2026-11-25 07:08:25.7645103 +0700 +07 expired=false
I1125 07:09:28.953478 11163 browser.go:265] token refreshed, new expiry=2026-11-25 08:09:27.953478 +0700 +07
E1125 07:10:26.704429 4163 errorreport.go:285] agent executor error: generating and executing: UNAUTHENTICATED (code 401): Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
Seconding the suggestion above to recognize UNAUTHENTICATED (code 401) in AntigravityTurnOutcome.ts and retry once when the token is valid/refreshed on disk while the upstream Antigravity CLI issue (google-antigravity/antigravity-cli#1091) is being fixed.
Reported with Gemini 4 Neon (Antigravity) in T3 Code.
Confirming this still reproduces on the latest managed CLI (Antigravity CLI 1.5.16) + T3 Code Nightly 0.1.12-nightly.20261124.5209 (macOS arm64, oauth-personal, gemini-4-neon):
- Two concurrent long-running threads hit
UNAUTHENTICATED(retryable: false) 13 seconds apart at the exact hourly OAuth boundary (12:24:42Zand12:24:55Z), and again 2 hours later at14:24:48Z— manually sendingcontinueresumes cleanly.
Not duplicating details since the root cause and fix in #40921 already cover this well — just adding the 1.5.16 + 20261124.5209 data point. (Posted by Gemini 4 Neon via Antigravity on Marcus's behalf.)
Confirming this hits hard under concurrent delegated subagents (delegate_task) on T3 Code Beta 0.1.12 + Antigravity CLI 1.5.14 (macOS arm64, oauth-personal, gemini-4-hydrogen).
High-concurrency blast radius observed
With 19 concurrent delegated Antigravity subagents running in parallel:
- Every subagent process spawned within the same hour loaded the exact same token expiry (
00:40:00.961 +0800) from the shared profileantigravity-oauth-tokenfile. - At the hourly boundary (
00:39:51–00:40:49), 21 concurrentantigravity acpprocesses all independently refreshed againstoauth2.googleapis.com/token, and 8 active delegated subagents failed in a single 2-minute wave (00:40:12–00:42:40) withUNAUTHENTICATED (code 401). - Immediately spawning resume delegates succeeded without re-authenticating (the token on disk was already valid until
01:40:48).
Two edge cases worth ensuring #40921 covers
- Delegated subagent turns (
delegate_task): Unlike interactive threads where a user can typecontinue, a failed delegated subagent permanently transitions tofailedand forces the parent orchestrator to re-delegate. Auto-resuming once on transientUNAUTHENTICATED (code 401)for delegated turns as well would avoid cascading subagent failures at every hourly boundary. pre-invocation hook: context summarization401 variant: In addition togenerating and executing: UNAUTHENTICATED (code 401), one of the 8 failed subagents failed on context summarization 17 seconds afterbrowser.go:265refreshed:
(The ACP error surfaced to T3 still containsI1127 00:39:55.792368 9020 browser.go:265] token refreshed, new expiry=2026-11-27 01:39:54.792306 +0800 CST E1127 00:40:12.797754 600 errorreport.go:282] agent executor error: pre-invocation hook: context summarization: UNAUTHENTICATED (code 401): Request had invalid authentication credentials...Request had invalid authentication credentials. Expected OAuth 2 access token..., so matching on the 401 /UNAUTHENTICATEDcredential error rather than onlygenerating and executingwill catch both.)
Also added the full single-session + concurrent log breakdown to upstream google-antigravity/antigravity-cli#1091.