Skip to content

Commit 3646402

Browse files
saphidclaude
andcommitted
fix(grok): failed Grok model switch in text generation shows Grok's error message
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 8764b1b commit 3646402

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,24 @@ it.layer(layerGrokTextGenerationTest)("GrokTextGeneration", (it) => {
155155
}),
156156
),
157157
);
158+
159+
it.effect("keeps Grok's error message when switching models fails", () =>
160+
withFakeAcpGrok({}, (textGeneration) =>
161+
Effect.gen(function* () {
162+
const error = yield* textGeneration
163+
.generateThreadTitle({
164+
cwd: process.cwd(),
165+
message: "the lint job is red",
166+
modelSelection: createModelSelection(
167+
ProviderInstanceId.make("grok"),
168+
"grok-mock-missing",
169+
),
170+
})
171+
.pipe(Effect.flip);
172+
expect(error.detail).toBe(
173+
"Failed to set Grok ACP base model for text generation: Unknown Grok model",
174+
);
175+
}),
176+
),
177+
);
158178
});

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export const makeGrokTextGeneration = Effect.fn("makeGrokTextGeneration")(functi
7676
mapError: (cause) =>
7777
new TextGenerationError({
7878
operation,
79-
detail: "Failed to set Grok ACP base model for text generation.",
79+
detail: isAcpRequestError(cause)
80+
? `Failed to set Grok ACP base model for text generation: ${cause.errorMessage}`
81+
: "Failed to set Grok ACP base model for text generation.",
8082
cause,
8183
}),
8284
});

0 commit comments

Comments
 (0)