Skip to content

Commit f354ec0

Browse files
t3dotggclaude
andcommitted
fix(server): Grok probes with no discovered models keep cached models
A probe where ACP initialize and `grok models` both list nothing fell back to the built-in model and reported ready, so the registry dropped cached gateway models. It now reports a warning, which keeps them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d0310e7 commit f354ec0

4 files changed

Lines changed: 33 additions & 10 deletions

File tree

‎apps/server/scripts/acp-mock-agent.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const emitGrokMonitorPostTurnPoll = process.env.T3_ACP_EMIT_GROK_MONITOR_POST_TU
5252
const emitGrokBackgroundTaskStarted = process.env.T3_ACP_EMIT_GROK_BACKGROUND_TASK_STARTED === "1";
5353
const emitGrokBackgroundTaskPoll = process.env.T3_ACP_GROK_BACKGROUND_TASK_COMPLETION === "poll";
5454
const emitForeignSessionUpdates = process.env.T3_ACP_EMIT_FOREIGN_SESSION_UPDATES === "1";
55+
const omitInitializeModelState = process.env.T3_ACP_OMIT_INITIALIZE_MODEL_STATE === "1";
5556
const waitForResumeRelease = process.env.T3_ACP_WAIT_FOR_RESUME_RELEASE === "1";
5657
const completeFirstPromptOnCancel = process.env.T3_ACP_COMPLETE_FIRST_PROMPT_ON_CANCEL === "1";
5758
const floodStderr = process.env.T3_ACP_FLOOD_STDERR === "1";
@@ -576,7 +577,7 @@ const program = Effect.gen(function* () {
576577
return {
577578
protocolVersion: 2,
578579
info: { name: "t3-acp-mock-agent", version: "0.0.0" },
579-
_meta: { modelState: modelState() },
580+
...(omitInitializeModelState ? {} : { _meta: { modelState: modelState() } }),
580581
capabilities: {
581582
session: {
582583
...(supportsSessionLifecycle ? { fork: {}, additionalDirectories: {} } : {}),

‎apps/server/src/provider/GrokProvider.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,27 @@ it.layer(NodeServices.layer)("checkGrokProviderStatus", (it) => {
352352
}),
353353
);
354354

355+
it.effect("warns instead of reporting ready when no models are discovered", () =>
356+
Effect.gen(function* () {
357+
const snapshot = yield* Effect.scoped(
358+
Effect.gen(function* () {
359+
const grokPath = yield* writeFakeGrokCli({
360+
modelsOutput: "You are logged in with grok.com.\n",
361+
acp: true,
362+
});
363+
return yield* checkGrokProviderStatus(
364+
decodeGrokSettings({ enabled: true, binaryPath: grokPath }),
365+
{ ...process.env, XAI_API_KEY: "", T3_ACP_OMIT_INITIALIZE_MODEL_STATE: "1" },
366+
);
367+
}),
368+
);
369+
370+
expect(snapshot.status).toBe("warning");
371+
expect(snapshot.message).toContain("did not list any models");
372+
expect(snapshot.models.map((model) => model.slug)).toEqual(["grok-build"]);
373+
}),
374+
);
375+
355376
it.effect("treats XAI_API_KEY as authenticated regardless of CLI login state", () =>
356377
Effect.gen(function* () {
357378
const snapshot = yield* Effect.scoped(

‎apps/server/src/provider/ProviderRegistry.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ const shouldRetainMissingProviderModels = (provider: ServerProvider): boolean =>
180180
}
181181

182182
if (provider.driver === ProviderDriverKind.make("grok")) {
183-
// Grok reports ready only after ACP initialize returns its model list; the
184-
// pending, ACP-failed, and logged-out probes are warning/error.
183+
// Grok reports ready only after it discovers a model list; the pending,
184+
// ACP-failed, empty-inventory, and logged-out probes are warning/error.
185185
return !(provider.installed && provider.status === "ready");
186186
}
187187

‎packages/provider-grok/src/server/status.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,12 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
531531
discoveredModels.length > 0
532532
? grokModelsFromSettings(grokSettings.customModels, discoveredModels)
533533
: fallbackModels;
534+
// The registry replaces cached models on a ready probe, so a fallback-only list must not be ready.
535+
const incompleteMessage = acpFailed
536+
? "Grok CLI is installed but ACP initialize failed. Model options may be incomplete."
537+
: discoveredModels.length === 0
538+
? "Grok CLI did not list any models. Model options may be incomplete."
539+
: undefined;
534540

535541
if (auth.status === "unauthenticated") {
536542
return buildServerProvider({
@@ -559,14 +565,9 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
559565
probe: {
560566
installed: true,
561567
version,
562-
status: acpFailed ? "warning" : "ready",
568+
status: incompleteMessage ? "warning" : "ready",
563569
auth,
564-
...(acpFailed
565-
? {
566-
message:
567-
"Grok CLI is installed but ACP initialize failed. Model options may be incomplete.",
568-
}
569-
: {}),
570+
...(incompleteMessage ? { message: incompleteMessage } : {}),
570571
},
571572
});
572573
});

0 commit comments

Comments
 (0)