@@ -11,6 +11,7 @@ import {
1111 type CodexSettings ,
1212 DEFAULT_TEXT_GENERATION_REASONING_EFFORT ,
1313 type ModelSelection ,
14+ type ServerProviderModel ,
1415 TextGenerationError ,
1516} from "@t3tools/contracts" ;
1617import { sanitizeBranchFragment , sanitizeFeatureBranchName } from "@t3tools/shared/git" ;
@@ -34,7 +35,7 @@ import {
3435 sanitizeThreadTitle ,
3536 toJsonSchemaObject ,
3637} from "./TextGenerationUtils.ts" ;
37- import { getModelSelectionStringOptionValue } from "@t3tools/shared/model" ;
38+ import { codexModelFamily , getModelSelectionStringOptionValue } from "@t3tools/shared/model" ;
3839import { getCodexServiceTierOptionValue } from "../codexModelOptions.ts" ;
3940
4041const CODEX_TIMEOUT_MS = 180_000 ;
@@ -46,6 +47,7 @@ const encodeJsonString = Schema.encodeEffect(Schema.fromJsonString(Schema.Unknow
4647export const makeCodexTextGeneration = Effect . fn ( "makeCodexTextGeneration" ) ( function * (
4748 codexConfig : CodexSettings ,
4849 environment ?: NodeJS . ProcessEnv ,
50+ getModels : Effect . Effect < ReadonlyArray < ServerProviderModel > > = Effect . succeed ( [ ] ) ,
4951) {
5052 const fileSystem = yield * FileSystem . FileSystem ;
5153 const path = yield * Path . Path ;
@@ -178,6 +180,14 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
178180 const outputPath = yield * writeTempFile ( operation , "codex-output" , "" ) ;
179181
180182 const runCodexCommand = Effect . fn ( "runCodexJson.runCodexCommand" ) ( function * ( ) {
183+ const models = yield * getModels ;
184+ const requestedModel = modelSelection . model ;
185+ const model =
186+ models . find ( ( candidate ) => candidate . slug === requestedModel ) ?. slug ??
187+ models . find (
188+ ( candidate ) => ! candidate . isCustom && codexModelFamily ( candidate . slug ) === requestedModel ,
189+ ) ?. slug ??
190+ requestedModel ;
181191 const launchArgs = resolveCodexLaunchArgs ( codexConfig . launchArgs , resolvedEnvironment ) ;
182192 const reasoningEffort =
183193 getModelSelectionStringOptionValue ( modelSelection , "reasoningEffort" ) ??
@@ -193,7 +203,7 @@ export const makeCodexTextGeneration = Effect.fn("makeCodexTextGeneration")(func
193203 "-s" ,
194204 "read-only" ,
195205 "--model" ,
196- modelSelection . model ,
206+ model ,
197207 "--config" ,
198208 `model_reasoning_effort="${ reasoningEffort } "` ,
199209 ...( serviceTier ? [ "--config" , `service_tier="${ serviceTier } "` ] : [ ] ) ,
0 commit comments