Skip to content

Commit 43d7bf2

Browse files
fix(server): text generation falls back when the selected provider's CLI is missing
Thread titles and other text generation stayed on the selected provider even when its CLI could not be found, so every attempt failed. The preflight that already switches away from an exhausted usage window now also switches when the selected snapshot is enabled but not installed with an error status. A not-yet-checked (pending) snapshot keeps the selection. Fixes #26962 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 60c0063 commit 43d7bf2

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

‎apps/server/src/textGeneration/CodexTextGeneration.test.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ it.layer(layerCodexTextGenerationTest)("CodexTextGeneration", (it) => {
444444
);
445445
});
446446

447-
const PREFLIGHT_PRIMARY_STATES = ["ready", "exhausted", "not installed"] as const;
447+
const PREFLIGHT_PRIMARY_STATES = ["ready", "pending", "exhausted", "not installed"] as const;
448448

449449
it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (primaryState) =>
450450
Effect.gen(function* () {
@@ -470,6 +470,9 @@ it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (prima
470470
models: [],
471471
slashCommands: [],
472472
skills: [],
473+
...(primaryState === "pending" && instanceId === primary
474+
? { installed: false, status: "warning", auth: { status: "unknown" } }
475+
: {}),
473476
...(primaryState === "not installed" && instanceId === primary
474477
? { installed: false, status: "error", auth: { status: "unknown" } }
475478
: {}),
@@ -531,7 +534,7 @@ it.effect.each(PREFLIGHT_PRIMARY_STATES)("text generation preflight: %s", (prima
531534
}),
532535
).toEqual({ title: "Generated title" });
533536
expect(calls).toEqual([
534-
primaryState !== "ready"
537+
primaryState === "exhausted" || primaryState === "not installed"
535538
? {
536539
instanceId: fallback,
537540
model:

‎apps/server/src/textGeneration/TextGeneration.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,11 @@ export const make = Effect.gen(function* () {
8686
),
8787
);
8888
const now = DateTime.toEpochMillis(yield* DateTime.now);
89-
const limited = exhaustedUsageWindow(
90-
snapshots.find((provider) => provider.instanceId === selection.instanceId),
91-
now,
92-
selection.model,
93-
);
94-
if (limited) {
89+
const selected = snapshots.find((provider) => provider.instanceId === selection.instanceId);
90+
// A pending snapshot is also not installed, but only a failed probe reports an error.
91+
const missing =
92+
selected?.enabled === true && !selected.installed && selected.status === "error";
93+
if (missing || exhaustedUsageWindow(selected, now, selection.model)) {
9594
const settings = yield* serverSettings.getSettings.pipe(
9695
Effect.mapError(
9796
(cause) =>

0 commit comments

Comments
 (0)