fix(codex): preserve qualified model ids in selection and generation (#9921)
This commit is contained in:
1 parent
cd64ad384e
commit
a92161a050
8 files changed
+128
-14
No files matched your search
@@ -134,6 +134,7 @@ function withFakeCodexEnv<A, E, R>(
|
||||
input: FakeCodexInput & {
|
||||
launchArgs?: string;
|
||||
environment?: NodeJS.ProcessEnv;
|
||||
models?: ReadonlyArray<string>;
|
||||
},
|
||||
effectFn: (textGeneration: TextGeneration.TextGeneration["Service"]) => Effect.Effect<A, E, R>,
|
||||
) {
|
||||
@@ -142,12 +143,44 @@ function withFakeCodexEnv<A, E, R>(
|
||||
const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3code-codex-text-" });
|
||||
const codexPath = yield* makeFakeCodexBinary(tempDir, input);
|
||||
const config = decodeCodexSettings({ binaryPath: codexPath, launchArgs: input.launchArgs });
|
||||
const textGeneration = yield* makeCodexTextGeneration(config, input.environment);
|
||||
const textGeneration = yield* makeCodexTextGeneration(
|
||||
config,
|
||||
input.environment,
|
||||
Effect.succeed(
|
||||
(input.models ?? []).map((slug) => ({
|
||||
slug,
|
||||
name: slug,
|
||||
isCustom: false,
|
||||
capabilities: null,
|
||||
})),
|
||||
),
|
||||
);
|
||||
return yield* effectFn(textGeneration);
|
||||
}).pipe(Effect.scoped);
|
||||
}
|
||||
|
||||
it.layer(CodexTextGenerationTestLayer)("CodexTextGeneration", (it) => {
|
||||
for (const selectedModel of ["gpt-5.6-luna", "openai.gpt-5.6-luna"]) {
|
||||
it.effect(`dispatches the qualified live model for ${selectedModel}`, () =>
|
||||
withFakeCodexEnv(
|
||||
{
|
||||
output: JSON.stringify({ title: "Bedrock title" }),
|
||||
models: ["openai.gpt-5.6-luna"],
|
||||
requireArg: "--model openai.gpt-5.6-luna",
|
||||
forbidArg: "--model gpt-5.6-luna",
|
||||
},
|
||||
(textGeneration) =>
|
||||
Effect.gen(function* () {
|
||||
const result = yield* textGeneration.generateThreadTitle({
|
||||
cwd: process.cwd(),
|
||||
message: "Describe this change",
|
||||
modelSelection: createModelSelection(ProviderInstanceId.make("codex"), selectedModel),
|
||||
});
|
||||
expect(result.title).toBe("Bedrock title");
|
||||
}),
|
||||
),
|
||||
);
|
||||
}
|
||||
it.effect("generates and sanitizes commit messages without branch by default", () =>
|
||||
withFakeCodexEnv(
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
type CodexSettings,
|
||||
DEFAULT_TEXT_GENERATION_REASONING_EFFORT,
|
||||
type ModelSelection,
|
||||
type ServerProviderModel,
|
||||
TextGenerationError,
|
||||
} from "@t3tools/contracts";
|
||||
import { sanitizeBranchFragment, sanitizeFeatureBranchName } from "@t3tools/shared/git";
|
||||
@@ -34,7 +35,7 @@ import {
|
||||
sanitizeThreadTitle,
|
||||
toJsonSchemaObject,
|
||||
} from "./TextGenerationUtils.ts";
|
||||
import { getModelSelectionStringOptionValue } from "@t3tools/shared/model";
|
||||
import { codexModelFamily, getModelSelectionStringOptionValue } from "@t3tools/shared/model";
|
||||
import { getCodexServiceTierOptionValue } from "../codexModelOptions.ts";
|
||||
|
||||
const CODEX_TIMEOUT_MS = 180_000;
|
||||
@@ -46,6 +47,7 @@ const encodeJsonString = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknow
|
||||
export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(function* (
|
||||
codexConfig: CodexSettings,
|
||||
environment?: NodeJS.ProcessEnv,
|
||||
getModels: Effect.Effect<ReadonlyArray<ServerProviderModel>> = Effect.succeed([]),
|
||||
) {
|
||||
const fileSystem = yield* FileSystem.FileSystem;
|
||||
const path = yield* Path.Path;
|
||||
@@ -178,6 +180,14 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
|
||||
const outputPath = yield* writeTempFile(operation, "codex-output", "");
|
||||
|
||||
const runCodexCommand = Effect.fn("runCodexJson.runCodexCommand")(function* () {
|
||||
const models = yield* getModels;
|
||||
const requestedModel = modelSelection.model;
|
||||
const model =
|
||||
models.find((candidate) => candidate.slug === requestedModel)?.slug ??
|
||||
models.find(
|
||||
(candidate) => !candidate.isCustom && codexModelFamily(candidate.slug) === requestedModel,
|
||||
)?.slug ??
|
||||
requestedModel;
|
||||
const launchArgs = resolveCodexLaunchArgs(codexConfig.launchArgs, resolvedEnvironment);
|
||||
const reasoningEffort =
|
||||
getModelSelectionStringOptionValue(modelSelection, "reasoningEffort") ??
|
||||
@@ -193,7 +203,7 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
|
||||
"-s",
|
||||
"read-only",
|
||||
"--model",
|
||||
modelSelection.model,
|
||||
model,
|
||||
"--config",
|
||||
`model_reasoning_effort="${reasoningEffort}"`,
|
||||
...(serviceTier ? ["--config", `service_tier="${serviceTier}"`] : []),
|
||||
|
||||
Reference in new issue
Block a user