Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions apps/server/src/provider/Layers/CodexProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
import { resolveSpawnCommand } from "@t3tools/shared/shell";
import { codexAppServerArgs, resolveCodexLaunchArgs } from "./codexLaunchArgs.ts";
import {
AUTH_PROBE_TIMEOUT_MS,
buildServerProvider,
COMPACT_SLASH_COMMAND,
type ServerProviderDraft,
Expand Down Expand Up @@ -62,6 +61,9 @@ type CodexRateLimitsProbe =
| { readonly failure: string };

const CODEX_APP_SERVER_PROBE_FORCE_KILL_AFTER = "2 seconds" as const;
// Codex's probe includes the app-server handshake, account, models, and skills. On Windows the
// command shim and concurrent startup probes can legitimately take longer than the shared 10s.
const CODEX_AUTH_PROBE_TIMEOUT_MS = 20_000;

const CODEX_PRESENTATION = {
displayName: "Codex",
Expand Down Expand Up @@ -608,7 +610,7 @@ export const checkCodexProviderStatus = Effect.fn("checkCodexProviderStatus")(fu
environment: resolvedEnvironment,
}).pipe(
Effect.scoped,
Effect.timeoutOption(Duration.millis(AUTH_PROBE_TIMEOUT_MS)),
Effect.timeoutOption(Duration.millis(CODEX_AUTH_PROBE_TIMEOUT_MS)),
Effect.result,
);

Expand Down
16 changes: 15 additions & 1 deletion apps/server/src/provider/Layers/ProviderRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,20 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
}),
);

it.effect("allows a slow Codex app-server probe to finish", () =>
Effect.gen(function* () {
const statusFiber = yield* checkCodexProviderStatus(defaultCodexSettings, () =>
Effect.sleep("15 seconds").pipe(Effect.as(makeCodexProbeSnapshot())),
).pipe(Effect.forkChild);

yield* Effect.yieldNow;
yield* TestClock.adjust("15 seconds");

const status = yield* Fiber.join(statusFiber);
assert.strictEqual(status.status, "ready");
}),
);

it.effect("closes the app-server probe scope when provider status times out", () =>
Effect.gen(function* () {
const killCalls = yield* Ref.make(0);
Expand All @@ -539,7 +553,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, ServerSettingsModule.layerTest(), Te
);

yield* Effect.yieldNow;
yield* TestClock.adjust("11 seconds");
yield* TestClock.adjust("21 seconds");
yield* Effect.yieldNow;

const status = yield* Fiber.join(statusFiber);
Expand Down
Loading