Skip to content

Commit 28fd524

Browse files
StiensWoutclaude
andcommitted
fix(server): Antigravity refresh errors use fixed text for the agent's reason
The refresh error no longer copies Antigravity's data.details. A received "python-socks is required to use a SOCKS proxy" maps to fixed canonical text; any other agent text stays only in cause. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3ce9d3b commit 28fd524

2 files changed

Lines changed: 32 additions & 34 deletions

File tree

‎apps/server/src/provider/Drivers/AntigravityDriver.test.ts‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
493493
);
494494

495495
it.effect.skipIf(windowsHost)(
496-
"shows the agent's error details when session creation fails and keeps the catalog",
496+
"reports the missing SOCKS dependency when session creation fails and keeps the catalog",
497497
() =>
498498
Effect.gen(function* () {
499499
const h = yield* makeHarness();
@@ -514,32 +514,38 @@ it.layer(layerTest)("AntigravityDriver", (it) => {
514514
);
515515

516516
it.effect.skipIf(windowsHost)(
517-
"bounds agent error details to one line and ignores details that are not text",
517+
"never copies unrecognized agent error details into the refresh error",
518518
() =>
519519
Effect.gen(function* () {
520520
const h = yield* makeHarness();
521+
yield* h.refresh();
522+
const before = yield* h.instance.snapshot.getSnapshot;
521523
const generic =
522524
"Could not refresh Antigravity models. The previous model list is unchanged.";
523-
h.controls.selected = yield* h.makeExecutable("runtime traceback", {
525+
const secret = "https://accounts.example.test/o/oauth2?code=sk-secret-123";
526+
h.controls.selected = yield* h.makeExecutable("runtime socks with extra", {
524527
newSessionErrorData: {
525-
details: `Traceback (most recent call last):\n File "agent.py"\n${"x".repeat(2_000)}`,
528+
details: `Traceback (most recent call last):\n proxy ${secret}\npython-socks is required to use a SOCKS proxy`,
526529
},
527530
});
528-
const bounded = yield* h.refresh().pipe(Effect.flip);
529-
expect(bounded.detail.startsWith(`${generic} Antigravity reported: Traceback`)).toBe(true);
530-
expect(bounded.detail).not.toContain("\n");
531-
expect(bounded.detail.length).toBeLessThanOrEqual(generic.length + 330);
532-
expect(bounded.detail.endsWith("…")).toBe(true);
531+
const known = yield* h.refresh().pipe(Effect.flip);
532+
expect(known.detail).toBe(
533+
`${generic} Antigravity reported: python-socks is required to use a SOCKS proxy`,
534+
);
533535

534536
for (const [name, data] of [
537+
["runtime unknown details", { details: `Token refresh failed for ${secret}` }],
535538
["runtime object details", { details: { stack: "secret frame", env: { HOME: "/" } } }],
536-
["runtime blank details", { details: " \n " }],
537-
["runtime no details", ["python-socks"]],
539+
["runtime no details", ["python-socks is required to use a SOCKS proxy"]],
538540
] as const) {
539541
h.controls.selected = yield* h.makeExecutable(name, { newSessionErrorData: data });
540542
const error = yield* h.refresh().pipe(Effect.flip);
541543
expect(error.detail).toBe(generic);
542544
}
545+
const after = yield* h.instance.snapshot.getSnapshot;
546+
expect(after.models).toEqual(before.models);
547+
expect(after.auth).toEqual(before.auth);
548+
expect(JSON.stringify(after)).not.toContain("sk-secret-123");
543549
yield* h.assertClosed;
544550
}).pipe(Effect.scoped),
545551
);

‎apps/server/src/provider/Drivers/AntigravityDriver.ts‎

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,28 +71,23 @@ const decodeSettings = Schema.decodeSync(AntigravitySettings);
7171
const isNodeRuntimeUnavailableError = Schema.is(NodeRuntimeUnavailableError);
7272
const isAcpRequestError = Schema.is(AcpErrors.AcpRequestError);
7373
const isAcpErrorDetails = Schema.is(Schema.Struct({ details: Schema.String }));
74-
const MAX_AGENT_DETAILS_LENGTH = 300;
74+
const REFRESH_FAILED =
75+
"Could not refresh Antigravity models. The previous model list is unchanged.";
76+
// The websockets ImportError Antigravity's runtime puts in `data.details` of its
77+
// "Internal error" when a system SOCKS proxy applies to its local harness (#16911).
78+
const PYTHON_SOCKS_REQUIRED = "python-socks is required to use a SOCKS proxy";
7579

7680
/**
77-
* Appends the reason Antigravity sent with a JSON-RPC error, bounded to one
78-
* line. Its runtime answers "Internal error" and explains only in
79-
* `data.details`, for example "python-socks is required to use a SOCKS proxy".
80-
* Local and transport failures keep the given detail.
81+
* Fixed refresh failure text for an error Antigravity sent. Recognized reasons
82+
* get canonical text; the agent's own text is never copied and stays in `cause`.
8183
*/
82-
function withAgentDetails(detail: string, cause: unknown) {
83-
if (
84-
!isAcpRequestError(cause) ||
85-
cause.operation !== "receive-response" ||
86-
!isAcpErrorDetails(cause.data)
87-
)
88-
return detail;
89-
const details = cause.data.details.replace(/\s+/gu, " ").trim();
90-
if (!details) return detail;
91-
const bounded =
92-
details.length > MAX_AGENT_DETAILS_LENGTH
93-
? `${details.slice(0, MAX_AGENT_DETAILS_LENGTH - 1)}…`
94-
: details;
95-
return `${detail} Antigravity reported: ${bounded}`;
84+
function refreshFailureDetail(cause: unknown) {
85+
return isAcpRequestError(cause) &&
86+
cause.operation === "receive-response" &&
87+
isAcpErrorDetails(cause.data) &&
88+
cause.data.details.includes(PYTHON_SOCKS_REQUIRED)
89+
? `${REFRESH_FAILED} Antigravity reported: ${PYTHON_SOCKS_REQUIRED}`
90+
: REFRESH_FAILED;
9691
}
9792

9893
export type AntigravityDriverEnv =
@@ -521,10 +516,7 @@ export const AntigravityDriver: ProviderDriver<
521516
: cause._tag === "ProviderSetupError" &&
522517
(cause.operation === "configure" || cause.operation === "start")
523518
? cause.detail
524-
: withAgentDetails(
525-
"Could not refresh Antigravity models. The previous model list is unchanged.",
526-
cause,
527-
),
519+
: refreshFailureDetail(cause),
528520
cause,
529521
}),
530522
),

0 commit comments

Comments
 (0)