The Codex readiness check and the second-model review pick the same model for a custom Codex provider (GST-3089) (#4491)

With a custom Codex provider, `gstack-codex-probe role-ready` and
`gstack-outside-voice run --runner codex-cli` now resolve the
plan-review model the same way, so a session no longer skips a review
that would have run.

Why: the check refused a `config.toml` naming `gpt-6-astra` while the
runner ran it, and a day-one eval session dropped the second-model
review in every phase.

Nothing to do: a custom provider naming the frontier catalog ID just
works; any other name now says how to opt in.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-18 16:44:07 +00:00
1 parent b6ca54ec09
commit 45f879b534
8 files changed
+215 -20

No files matched your search

+27 -9
View File
@@ -145,9 +145,25 @@ export function resolveCodexRuntimeModel(opts: {
};
if (opts.explicit) return chosen('explicit request', opts.explicit);
if (env.GSTACK_CODEX_MODEL) return chosen('GSTACK_CODEX_MODEL', env.GSTACK_CODEX_MODEL);
const named = codexConfigModel({ ...opts, env });
if (named.value === null) return { kind: opts.kind, model: CODEX_DEFAULT_MODEL, source: `gstack default (${named.source})` };
return chosen(named.source, named.value);
}
const home = opts.home ?? env.HOME ?? os.homedir();
const codexHome = opts.codexHome ?? env.CODEX_HOME ?? path.join(home, '.codex');
/**
* The model Codex's own config.toml names for this invocation kind
* (`review_model` first for native review, then the legacy active profile's
* model, then `model`). `value` is null when it names none, and `source`
* then says what was missing. Shared by the runtime and plan-review records.
*/
function codexConfigModel(opts: {
kind: CodexInvocationKind;
env: Record<string, string | undefined>;
codexHome?: string;
home?: string;
}): { value: string | null; source: string } {
const home = opts.home ?? opts.env.HOME ?? os.homedir();
const codexHome = opts.codexHome ?? opts.env.CODEX_HOME ?? path.join(home, '.codex');
if (!path.isAbsolute(codexHome)) {
throw new Error(`CODEX_HOME '${sanitize(codexHome)}' is not an absolute path, so its config.toml model cannot be read. ${REPAIR}`);
}
@@ -156,9 +172,7 @@ export function resolveCodexRuntimeModel(opts: {
try {
raw = fs.readFileSync(configPath, 'utf8');
} catch (error) {
if ((error as NodeJS.ErrnoException).code === 'ENOENT') {
return { kind: opts.kind, model: CODEX_DEFAULT_MODEL, source: `gstack default (no ${stripControl(configPath)})` };
}
if ((error as NodeJS.ErrnoException).code === 'ENOENT') return { value: null, source: `no ${stripControl(configPath)}` };
throw new Error(`Could not read ${sanitize(configPath)}. ${REPAIR}`);
}
let parsed: Record<string, unknown>;
@@ -178,9 +192,9 @@ export function resolveCodexRuntimeModel(opts: {
for (const [source, value] of candidates) {
if (value === undefined) continue;
if (typeof value !== 'string') throw new Error(`${sanitize(source)} is not a string. ${REPAIR}`);
return chosen(source, value);
return { value, source };
}
return { kind: opts.kind, model: CODEX_DEFAULT_MODEL, source: `gstack default (no model in ${stripControl(configPath)})` };
return { value: null, source: `no model in ${stripControl(configPath)}` };
}
export interface CodexPlanReviewSelection extends CodexRuntimeModelSelection {
@@ -204,7 +218,11 @@ export function resolveCodexPlanReviewModel(opts: {
cwd?: string;
}): CodexPlanReviewSelection {
const env = opts.env ?? process.env;
const selection = resolvePlanReviewModel({ provider: 'openai', requestedModel: opts.explicit || undefined, env, cwd: opts.cwd });
const nativeModel = () => {
const named = codexConfigModel({ ...opts, env });
return named.value === null ? null : { model: named.value.trim(), label: stripControl(named.source) };
};
const selection = resolvePlanReviewModel({ provider: 'openai', requestedModel: opts.explicit || undefined, env, cwd: opts.cwd, nativeModel });
const repair = stripControl(selectionRepair(selection).join('; '));
if (selection.status === 'selected') {
const model = selection.requestedModel;
@@ -219,7 +237,7 @@ export function resolveCodexPlanReviewModel(opts: {
function policyFailure(error: unknown): string {
if (!(error instanceof ModelPolicyError)) return (error as Error).message;
return [`${error.problem} ${error.cause}`.trim(), ...error.repair.map(step => `Repair: ${step}`), `Docs: ${error.docs}`].join('\n');
return [`${error.problem} ${error.cause}`.trim(), ...error.repair.map(step => `Repair: ${step}`), `Docs: ${error.docs}`, `CODEX_MODEL_POLICY: ${error.reason}`].join('\n');
}
function readArg(name: string): string | undefined {