@devries-cameron20 / t3code-1 / commits / 2a7bd1673c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(provider-grok): Grok health checks no longer start Grok's updater (#18075)

Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Aaron Queen committed Oct 15, 2026 at 21:05 UTC 2a7bd1673c7bdad4304b7771944e73c29ecd3c01
5 files changed +84 -18
apps/server/src/provider/GrokProvider.test.ts
+25 -5
@@ -402,7 +402,11 @@ it.layer(NodeServices.layer)("checkGrokProviderStatus", (it) => {
402
403 // A stand-in for the Grok CLI: `--version` and `models` print canned text,
404 // and `agent stdio` execs the mock ACP agent so `initialize` returns model metadata.
405 - const writeFakeGrokCli = (input: { readonly modelsOutput: string; readonly acp: boolean }) =>
405 + const writeFakeGrokCli = (input: {
406 + readonly modelsOutput: string;
407 + readonly acp: boolean;
408 + readonly updateLogPath?: string;
409 + }) =>
410 Effect.gen(function* () {
411 const fs = yield* FileSystem.FileSystem;
412 const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-grok-probe-" });
@@ -411,6 +415,14 @@ it.layer(NodeServices.layer)("checkGrokProviderStatus", (it) => {
415 directory: dir,
416 name: "grok",
417 source: [
418 + ...(input.updateLogPath
419 + ? [
420 + 'import { appendFileSync as appendUpdateAttempt } from "node:fs";',
421 + 'if (process.env.GROK_DISABLE_AUTOUPDATER !== "1") {',
422 + ` appendUpdateAttempt(${JSON.stringify(input.updateLogPath)}, "update\\n");`,
423 + "}",
424 + ]
425 + : []),
426 'if (process.argv[2] === "--version") {',
427 ' process.stdout.write("grok 1.0.13\\n");',
428 " process.exit(0);",
@@ -426,21 +438,29 @@ it.layer(NodeServices.layer)("checkGrokProviderStatus", (it) => {
438 });
439 });
440
429 - it.effect("reports ready with ACP-discovered models when logged in", () =>
441 + it.effect("reports ready with ACP-discovered models without running startup updates", () =>
442 Effect.gen(function* () {
431 - const snapshot = yield* Effect.scoped(
443 + const environment = { ...process.env, XAI_API_KEY: "", GROK_DISABLE_AUTOUPDATER: "0" };
444 + const { snapshot, updateRan } = yield* Effect.scoped(
445 Effect.gen(function* () {
446 + const fs = yield* FileSystem.FileSystem;
447 + const dir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-grok-updater-" });
448 + const updateLogPath = NodePath.join(dir, "updates.log");
449 const grokPath = yield* writeFakeGrokCli({
450 modelsOutput: LOGGED_IN_MODELS_OUTPUT,
451 acp: true,
452 + updateLogPath,
453 });
437 - return yield* checkGrokProviderStatus(
454 + const snapshot = yield* checkGrokProviderStatus(
455 decodeGrokSettings({ enabled: true, binaryPath: grokPath }),
439 - { ...process.env, XAI_API_KEY: "" },
456 + environment,
457 );
458 + return { snapshot, updateRan: yield* fs.exists(updateLogPath) };
459 }),
460 );
461
462 + expect(updateRan).toBe(false);
463 + expect(environment.GROK_DISABLE_AUTOUPDATER).toBe("0");
464 expect(snapshot.status).toBe("ready");
465 expect(snapshot.version).toBe("1.0.13");
466 expect(snapshot.auth).toEqual({
packages/provider-grok/src/server/probeEnvironment.ts new
+12
@@ -0,0 +1,12 @@
1 +/**
2 + * Grok checks for a newer CLI when it launches. T3's health probes
3 + * (`grok --version`, `grok models`, `grok inspect --json`, ACP `initialize`)
4 + * run periodically in the background, so an update they start is invisible,
5 + * and on Windows it opens a console window for npm. Grok documents
6 + * `GROK_DISABLE_AUTOUPDATER=1` as process-scoped suppression, so probes set it
7 + * on a copy of the caller's environment. Sessions, text generation, and
8 + * `grok update` keep the caller's environment and update as the user configured.
9 + */
10 +export function grokProbeEnvironment(environment: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
11 + return { ...environment, GROK_DISABLE_AUTOUPDATER: "1" };
12 +}
packages/provider-grok/src/server/skills.test.ts
+32 -5
@@ -2,15 +2,20 @@ import { describe, expect, it } from "@effect/vitest";
2 import * as Effect from "effect/Effect";
3 import * as Sink from "effect/Sink";
4 import * as Stream from "effect/Stream";
5 +import type * as ChildProcess from "effect/process/ChildProcess";
6 import * as ChildProcessSpawner from "effect/process/ChildProcessSpawner";
7
8 import { discoverGrokSkills } from "./skills.ts";
9
10 const inspectPayload = (skills: ReadonlyArray<unknown>) => JSON.stringify({ skills });
11
11 -const makeInspectSpawner = (stdout: string, exitCode = 0, spawnCwds?: Array<string | undefined>) =>
12 +const makeInspectSpawner = (
13 + stdout: string,
14 + exitCode = 0,
15 + spawnOptions?: Array<ChildProcess.CommandOptions | undefined>,
16 +) =>
17 ChildProcessSpawner.make((command) => {
13 - spawnCwds?.push(command._tag === "StandardCommand" ? command.options.cwd : undefined);
18 + spawnOptions?.push(command._tag === "StandardCommand" ? command.options : undefined);
19 return Effect.succeed(
20 ChildProcessSpawner.makeHandle({
21 pid: ChildProcessSpawner.ProcessId(1),
@@ -142,7 +147,7 @@ describe("discoverGrokSkills", () => {
147 );
148
149 it.effect("spawns in the configured cwd and rejects a failed probe", () => {
145 - const spawnCwds: Array<string | undefined> = [];
150 + const spawnOptions: Array<ChildProcess.CommandOptions | undefined> = [];
151 const stdout = inspectPayload([
152 {
153 name: "kept",
@@ -154,11 +159,11 @@ describe("discoverGrokSkills", () => {
159 const skills = yield* discoverGrokSkills({ binaryPath: "grok" }, {}, "/workspaces/demo").pipe(
160 Effect.provideService(
161 ChildProcessSpawner.ChildProcessSpawner,
157 - makeInspectSpawner(stdout, 0, spawnCwds),
162 + makeInspectSpawner(stdout, 0, spawnOptions),
163 ),
164 );
165
161 - expect(spawnCwds).toEqual(["/workspaces/demo"]);
166 + expect(spawnOptions.map((options) => options?.cwd)).toEqual(["/workspaces/demo"]);
167 expect(skills.map((skill) => skill.name)).toEqual(["kept"]);
168
169 const failed = yield* discoverGrokSkills({ binaryPath: "grok" }).pipe(
@@ -171,4 +176,26 @@ describe("discoverGrokSkills", () => {
176 expect(failed._tag).toBe("Failure");
177 });
178 });
179 +
180 + // Workspace skill probes run on their own from the driver, outside the
181 + // status check, so they must suppress Grok's launch-time updater themselves.
182 + it.effect("disables Grok's updater for the probe without touching the caller's env", () => {
183 + const spawnOptions: Array<ChildProcess.CommandOptions | undefined> = [];
184 + const environment = { GROK_DISABLE_AUTOUPDATER: "0", GROK_HOME: "/home/dev/.grok" };
185 +
186 + return Effect.gen(function* () {
187 + yield* discoverGrokSkills({ binaryPath: "grok" }, environment, "/workspaces/demo").pipe(
188 + Effect.provideService(
189 + ChildProcessSpawner.ChildProcessSpawner,
190 + makeInspectSpawner(inspectPayload([]), 0, spawnOptions),
191 + ),
192 + );
193 +
194 + expect(spawnOptions[0]?.env).toEqual({
195 + GROK_DISABLE_AUTOUPDATER: "1",
196 + GROK_HOME: "/home/dev/.grok",
197 + });
198 + expect(environment.GROK_DISABLE_AUTOUPDATER).toBe("0");
199 + });
200 + });
201 });
packages/provider-grok/src/server/skills.ts
+4 -2
@@ -24,6 +24,7 @@ import * as ChildProcess from "effect/process/ChildProcess";
24 import { resolveSpawnCommand } from "@t3tools/shared/shell";
25
26 import { spawnAndCollect } from "@t3tools/provider-core/server/snapshotProbe";
27 +import { grokProbeEnvironment } from "./probeEnvironment.ts";
28
29 const GROK_SKILLS_PROBE_TIMEOUT_MS = 4_000;
30
@@ -103,15 +104,16 @@ export const discoverGrokSkills = Effect.fn("discoverGrokSkills")(function* (
104 cwd?: string,
105 ) {
106 const command = grokSettings.binaryPath || "grok";
107 + const probeEnvironment = grokProbeEnvironment(environment);
108 const inspectResult = yield* Effect.gen(function* () {
109 const spawnCommand = yield* resolveSpawnCommand(command, ["inspect", "--json"], {
108 - env: environment,
110 + env: probeEnvironment,
111 });
112 return yield* spawnAndCollect(
113 command,
114 ChildProcess.make(spawnCommand.command, spawnCommand.args, {
115 ...(cwd ? { cwd } : {}),
114 - env: environment,
116 + env: probeEnvironment,
117 shell: spawnCommand.shell,
118 }),
119 );
packages/provider-grok/src/server/status.ts
+11 -6
@@ -46,6 +46,7 @@ import {
46 } from "./acpSupport.ts";
47 import { sessionModelStateFromInitialize } from "@t3tools/provider-acp/server/runtimeModel";
48 import { discoverGrokSkills } from "./skills.ts";
49 +import { grokProbeEnvironment } from "./probeEnvironment.ts";
50
51 const GROK_PRESENTATION = {
52 displayName: "Grok",
@@ -398,10 +399,13 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
399 });
400 }
401
401 - const versionResult = yield* runGrokCliCommand(grokSettings, ["--version"], environment).pipe(
402 - Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS),
403 - Effect.result,
404 - );
402 + const probeEnvironment = grokProbeEnvironment(environment);
403 +
404 + const versionResult = yield* runGrokCliCommand(
405 + grokSettings,
406 + ["--version"],
407 + probeEnvironment,
408 + ).pipe(Effect.timeoutOption(VERSION_PROBE_TIMEOUT_MS), Effect.result);
409
410 if (Result.isFailure(versionResult)) {
411 const error = versionResult.failure;
@@ -465,7 +469,7 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
469 }
470
471 // `grok models` reports login state and model slugs without starting the agent.
468 - const modelsResult = yield* runGrokCliCommand(grokSettings, ["models"], environment).pipe(
472 + const modelsResult = yield* runGrokCliCommand(grokSettings, ["models"], probeEnvironment).pipe(
473 Effect.timeoutOption(AUTH_PROBE_TIMEOUT_MS),
474 Effect.result,
475 );
@@ -498,12 +502,13 @@ export const checkGrokProviderStatus = Effect.fn("checkGrokProviderStatus")(func
502 ? { status: "unauthenticated" }
503 : { status: "unknown" };
504
505 + // Skill discovery applies the probe environment itself.
506 const skills = yield* discoverGrokSkills(grokSettings, environment, cwd).pipe(
507 Effect.tapError((cause) => Effect.logDebug("Grok skill discovery failed.", { cause })),
508 Effect.orElseSucceed(() => []),
509 );
510
506 - const acpExit = yield* discoverGrokMetadataViaAcpInitialize(grokSettings, environment).pipe(
511 + const acpExit = yield* discoverGrokMetadataViaAcpInitialize(grokSettings, probeEnvironment).pipe(
512 Effect.timeoutOption(GROK_ACP_INITIALIZE_TIMEOUT_MS),
513 Effect.exit,
514 );