Skip to content

Commit 6a936b8

Browse files
only21milclaude
andcommitted
fix(server): stop retrying Antigravity session startup while sign-in is required
A session open that fails because Antigravity waits for Google sign-in now fails the run on the first attempt instead of retrying four more times. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3d00499 commit 6a936b8

6 files changed

Lines changed: 82 additions & 1 deletion

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ import * as Path from "effect/Path";
2222
import * as Stream from "effect/Stream";
2323
import { ChildProcessSpawner } from "effect/process";
2424
import type * as EffectAcpSchema from "effect-acp/compat";
25+
import * as EffectAcpErrors from "effect-acp/errors";
2526

2627
import * as ProviderHost from "@t3tools/provider-core/server/ProviderHost";
2728
import * as McpProviderSessions from "@t3tools/provider-core/server/McpProviderSessions";
2829
import * as TestProviderHost from "@t3tools/provider-testing/TestProviderHost";
2930
import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime";
3031
import { makeAntigravityAcpRuntime } from "../../provider/acp/AntigravityAcpSupport.ts";
3132
import { normalizeAntigravitySessionUpdate } from "../../provider/acp/AntigravityProtocol.ts";
33+
import { ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE } from "../../provider/antigravityAuthSupport.ts";
3234
import * as IdAllocator from "@t3tools/provider-core/server/IdAllocator";
3335
import * as ProviderAdapter from "@t3tools/provider-core/server/ProviderAdapter";
3436
import {
@@ -122,6 +124,43 @@ const layerSession = Layer.mergeAll(
122124
TestProviderHost.layer().pipe(Layer.provide(NodeServices.layer)),
123125
);
124126

127+
describe("AntigravityAdapterV2 session open", () => {
128+
it.effect("marks a session that waits for Google sign-in as needing sign-in", () =>
129+
Effect.gen(function* () {
130+
const instanceId = ProviderInstanceId.make("antigravity-sign-in-test");
131+
const adapter = yield* makeAntigravityAdapterV2({
132+
instanceId,
133+
selfInvocation: yield* resolveSelfInvocation(),
134+
makeRuntime: () =>
135+
Effect.fail(
136+
new EffectAcpErrors.AcpTransportError({
137+
detail: ANTIGRAVITY_SIGN_IN_REQUIRED_MESSAGE,
138+
cause: undefined,
139+
}),
140+
),
141+
withProcess: (_stop, task) => task,
142+
defaultModel: Effect.succeed(undefined),
143+
});
144+
const threadId = ThreadId.make("thread-antigravity-sign-in");
145+
const error = yield* adapter
146+
.openSession({
147+
threadId,
148+
providerSessionId: ProviderSessionId.make("provider-session-antigravity-sign-in"),
149+
modelSelection: { instanceId, model: "gemini-test-low" },
150+
runtimePolicy: ProviderAdapter.ProviderAdapterV2RuntimePolicy.make({
151+
runtimeMode: "full-access",
152+
interactionMode: "default",
153+
cwd: process.cwd(),
154+
}),
155+
})
156+
.pipe(Effect.flip);
157+
158+
assert.equal(error._tag, "ProviderAdapterOpenSessionError");
159+
assert.isTrue(error._tag === "ProviderAdapterOpenSessionError" && error.requiresSignIn);
160+
}).pipe(Effect.provide(layerSession), Effect.scoped),
161+
);
162+
});
163+
125164
describe("AntigravityAdapterV2 client file system", () => {
126165
it.effect("confines agent file requests to the workspace under full access", () =>
127166
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,
@@ -202,6 +203,7 @@ export function makeAntigravityAcpAdapterFlavor(
202203
extractSubagentUpdate: extractAntigravitySubagentUpdate,
203204
supportsImagePrompts: true,
204205
supportsCompaction: true,
206+
requiresSignIn: isAntigravitySignInRequiredError,
205207
};
206208
}
207209

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

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

1131+
effectIt.effect("fails the run without a retry when the provider needs sign-in", () =>
1132+
Effect.gen(function* () {
1133+
const harness = makeLocalCommandHarness({
1134+
text: "Continue",
1135+
openFailure: new ProviderAdapter.ProviderAdapterOpenSessionError({
1136+
driver: ProviderDriverKind.make("antigravity"),
1137+
providerSessionId: ProviderSessionId.make("new-provider-session"),
1138+
requiresSignIn: true,
1139+
}),
1140+
});
1141+
1142+
yield* harness.startWithRetry;
1143+
1144+
expect(harness.open).toHaveBeenCalledOnce();
1145+
expect(harness.projection().runs.at(-1)?.status).toBe("failed");
1146+
expect(harness.projection().turnItems).toMatchObject([
1147+
{
1148+
type: "error",
1149+
status: "failed",
1150+
failure: {
1151+
class: "provider_error",
1152+
message: "Failed to open antigravity provider session new-provider-session.",
1153+
},
1154+
},
1155+
]);
1156+
}),
1157+
);
1158+
11311159
effectIt.effect("does not terminalize a provider-session open interruption", () =>
11321160
Effect.gen(function* () {
11331161
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
@@ -68,6 +68,9 @@ export class ProviderTurnStartError extends Schema.TaggedError<ProviderTurnStart
6868
) {}
6969

7070
const isProviderTurnStartError = Schema.is(ProviderTurnStartError);
71+
const isProviderAdapterOpenSessionError = Schema.is(
72+
ProviderAdapter.ProviderAdapterOpenSessionError,
73+
);
7174

7275
/**
7376
* Claude refuses these before it reads the prompt: replacing a process running background work,
@@ -669,7 +672,12 @@ export const layer: Layer.Layer<
669672
}),
670673
);
671674
if (sessionResult._tag === "Failure") {
672-
if (input.willRetry === true) return yield* sessionResult.failure;
675+
const failure = sessionResult.failure;
676+
const requiresSignIn =
677+
"cause" in failure &&
678+
isProviderAdapterOpenSessionError(failure.cause) &&
679+
failure.cause.requiresSignIn === true;
680+
if (input.willRetry === true && !requiresSignIn) return yield* failure;
673681
yield* settleStartFailure({
674682
signal: "provider-session-open-failure",
675683
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
@@ -218,6 +218,7 @@ class AcpModelSelectionError extends Schema.TaggedError<AcpModelSelectionError>(
218218

219219
export interface AcpAdapterV2Flavor {
220220
readonly promptFailure?: (cause: unknown) => OrchestrationV2ProviderFailure;
221+
readonly requiresSignIn?: (cause: unknown) => boolean;
221222
/**
222223
* Runs before attachment paths, T3 instructions and native slash-command detection,
223224
* so a rewrite can turn the user's text into a native command.
@@ -8445,6 +8446,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
84458446
new ProviderAdapter.ProviderAdapterOpenSessionError({
84468447
driver,
84478448
providerSessionId: input.providerSessionId,
8449+
...(flavor.requiresSignIn?.(cause) === true ? { requiresSignIn: true } : {}),
84488450
cause,
84498451
}),
84508452
),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ export class ProviderAdapterOpenSessionError extends Schema.TaggedError<Provider
184184
{
185185
driver: ProviderDriverKind,
186186
providerSessionId: ProviderSessionId,
187+
/** Set when the provider waits for the user to sign in, which no retry can fix. */
188+
requiresSignIn: Schema.optional(Schema.Literal(true)),
187189
cause: Schema.optional(Schema.Defect()),
188190
},
189191
) {

0 commit comments

Comments
 (0)