Skip to content

Commit 99ff58a

Browse files
only21milclaudemaria-rcks
authored
fix(server): Antigravity stops retrying session startup while signed out (pingdotgg#24939)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: maria-rcks <[email protected]>
1 parent 9d38d68 commit 99ff58a

6 files changed

Lines changed: 101 additions & 1 deletion

File tree

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts‎

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import * as Path from "effect/Path";
2424
import * as Stream from "effect/Stream";
2525
import { ChildProcessSpawner } from "effect/process";
2626
import type * as EffectAcpSchema from "effect-acp/compat";
27+
import * as EffectAcpErrors from "effect-acp/errors";
2728

2829
import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
2930
import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
@@ -32,6 +33,7 @@ import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSession
3233
import { makeAntigravityAcpRuntime } from "../../provider/acp/AntigravityAcpSupport.ts";
3334
import { resolveAttachmentPath } from "../../attachmentStore.ts";
3435
import { normalizeAntigravitySessionUpdate } from "../../provider/acp/AntigravityProtocol.ts";
36+
import { ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE } from "../../provider/antigravityAuthSupport.ts";
3537
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
3638
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
3739
import {
@@ -126,6 +128,63 @@ const layerSession = Layer.mergeAll(
126128
TestProviderHost.layer().pipe(Layer.provide(NodeServices.layer)),
127129
);
128130

131+
describe("AntigravityAdapterV2 session open", () => {
132+
it.effect.each([
133+
{
134+
name: "browser sign-in",
135+
cause: new EffectAcpErrors.AcpTransportError({
136+
detail: ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE,
137+
cause: undefined,
138+
}),
139+
requiresSignIn: true,
140+
},
141+
{
142+
name: "ACP authentication required",
143+
cause: EffectAcpErrors.AcpRequestError.authRequired(),
144+
requiresSignIn: true,
145+
},
146+
{
147+
name: "transport failure",
148+
cause: new EffectAcpErrors.AcpTransportError({
149+
detail: "Connection closed",
150+
cause: undefined,
151+
}),
152+
requiresSignIn: undefined,
153+
},
154+
] as const)("classifies $name during session open", ({ cause, requiresSignIn }) =>
155+
Effect.gen(function* () {
156+
const instanceId = ProviderInstanceId.make("antigravity-sign-in-test");
157+
const adapter = yield* makeAntigravityAdapterV2({
158+
instanceId,
159+
selfInvocation: yield* resolveSelfInvocation(),
160+
makeRuntime: () => Effect.fail(cause),
161+
withProcess: (_stop, task) => task,
162+
// @effect-diagnostics-next-line effectSucceedWithVoid:off - This optional result requires undefined, not the wider void type.
163+
defaultModel: Effect.succeed(undefined),
164+
});
165+
const threadId = ThreadId.make("thread-antigravity-sign-in");
166+
const error = yield* adapter
167+
.openSession({
168+
threadId,
169+
providerSessionId: ProviderSessionId.make("provider-session-antigravity-sign-in"),
170+
modelSelection: { instanceId, model: "gemini-test-low" },
171+
runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
172+
runtimeMode: "full-access",
173+
interactionMode: "default",
174+
cwd: process.cwd(),
175+
}),
176+
})
177+
.pipe(Effect.flip);
178+
179+
assert.equal(error._tag, "ProviderAdapterOpenSessionError");
180+
assert.equal(
181+
error._tag === "ProviderAdapterOpenSessionError" && error.requiresSignIn,
182+
requiresSignIn,
183+
);
184+
}).pipe(Effect.provide(layerSession), Effect.scoped),
185+
);
186+
});
187+
129188
describe("AntigravityAdapterV2 client file system", () => {
130189
it.effect("serves confined reads and leaves edits to the agent's diff tools", () =>
131190
Effect.gen(function* () {

‎apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
makeAntigravityUserInputResponse,
3535
normalizeAntigravityToolCall,
3636
} from "../../provider/acp/AntigravityProtocol.ts";
37+
import { isAntigravitySignInRequiredError } from "../../provider/antigravityAuthSupport.ts";
3738
import {
3839
AcpProviderCapabilitiesV2,
3940
makeAcpAdapterV2,
@@ -238,6 +239,7 @@ export function makeAntigravityAcpAdapterFlavor(
238239
extractSubagentUpdate: extractAntigravitySubagentUpdate,
239240
supportsImagePrompts: true,
240241
supportsCompaction: true,
242+
requiresSignIn: isAntigravitySignInRequiredError,
241243
};
242244
}
243245

‎apps/server/src/orchestration-v2/ProviderTurnStartService.test.ts‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,6 +1304,34 @@ effectIt.effect("leaves the run starting when a session-open failure will be ret
13041304
}),
13051305
);
13061306

1307+
effectIt.effect("fails the run without a retry when the provider needs sign-in", () =>
1308+
Effect.gen(function* () {
1309+
const harness = makeLocalCommandHarness({
1310+
text: "Continue",
1311+
openFailure: new ProviderAdapter.ProviderAdapterOpenSessionError({
1312+
driver: ProviderDriverKind.make("antigravity"),
1313+
providerSessionId: ProviderSessionId.make("new-provider-session"),
1314+
requiresSignIn: true,
1315+
}),
1316+
});
1317+
1318+
yield* harness.startWithRetry;
1319+
1320+
expect(harness.open).toHaveBeenCalledOnce();
1321+
expect(harness.projection().runs.at(-1)?.status).toBe("failed");
1322+
expect(harness.projection().turnItems).toMatchObject([
1323+
{
1324+
type: "error",
1325+
status: "failed",
1326+
failure: {
1327+
class: "provider_error",
1328+
message: "Failed to open antigravity provider session new-provider-session.",
1329+
},
1330+
},
1331+
]);
1332+
}),
1333+
);
1334+
13071335
effectIt.effect("does not terminalize a provider-session open interruption", () =>
13081336
Effect.gen(function* () {
13091337
const harness = makeLocalCommandHarness({ text: "Continue", interruptOpen: true });

‎apps/server/src/orchestration-v2/ProviderTurnStartService.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ class WorktreeRecreateNoBaseError extends Schema.TaggedError<WorktreeRecreateNoB
9292
}
9393

9494
const isProviderTurnStartError = Schema.is(ProviderTurnStartError);
95+
const isProviderAdapterOpenSessionError = Schema.is(
96+
ProviderAdapter.ProviderAdapterOpenSessionError,
97+
);
9598

9699
/**
97100
* Claude refuses these before it reads the prompt: replacing a process running background work,
@@ -732,7 +735,12 @@ export const layer: Layer.Layer<
732735
}),
733736
);
734737
if (sessionResult._tag === "Failure") {
735-
if (input.willRetry === true) return yield* sessionResult.failure;
738+
const failure = sessionResult.failure;
739+
const requiresSignIn =
740+
"cause" in failure &&
741+
isProviderAdapterOpenSessionError(failure.cause) &&
742+
failure.cause.requiresSignIn === true;
743+
if (input.willRetry === true && !requiresSignIn) return yield* failure;
736744
yield* settleStartFailure({
737745
signal: "provider-session-open-failure",
738746
title: "Provider session failed to open",

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ export interface AcpAdapterV2Flavor {
224224
readonly promptCapabilities: EffectAcpSchema.AgentCapabilities["promptCapabilities"];
225225
}) => Effect.Effect<ReadonlyArray<EffectAcpSchema.ContentBlock>, EffectAcpErrors.AcpError>;
226226
readonly promptFailure?: (cause: unknown) => OrchestrationV2ProviderFailure;
227+
readonly requiresSignIn?: (cause: unknown) => boolean;
227228
/**
228229
* Runs before attachment paths, T3 instructions and native slash-command detection,
229230
* so a rewrite can turn the user's text into a native command.
@@ -8555,6 +8556,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
85558556
new ProviderAdapter.ProviderAdapterOpenSessionError({
85568557
driver,
85578558
providerSessionId: input.providerSessionId,
8559+
...(flavor.requiresSignIn?.(cause) === true ? { requiresSignIn: true } : {}),
85588560
cause,
85598561
}),
85608562
),

‎packages/provider-core/src/server/ProviderAdapter.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ export class ProviderAdapterOpenSessionError extends Schema.TaggedError<Provider
183183
{
184184
driver: ProviderDriverKind,
185185
providerSessionId: ProviderSessionId,
186+
requiresSignIn: Schema.optional(Schema.Literal(true)),
186187
cause: Schema.optional(Schema.Defect()),
187188
},
188189
) {

0 commit comments

Comments
 (0)