Skip to content

Commit 264cc99

Browse files
authored
fix(codex): run newly available models through native account auth (#127322)
1 parent 81ace37 commit 264cc99

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

‎extensions/codex/harness.test.ts‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,51 @@ describe("Codex agent harness supports()", () => {
248248
expect(!result.supported ? result.reason : undefined).toContain("not declared");
249249
});
250250

251+
it("lets explicitly selected Codex discover unlisted models with its own account", () => {
252+
expect(
253+
harness.supports({
254+
provider: "openai",
255+
modelId: "gpt-future",
256+
requestedRuntime: "codex",
257+
modelProvider: {
258+
requestTransportOverrides: "none",
259+
preparedAuth: { source: "harness" },
260+
},
261+
}),
262+
).toEqual({ supported: true, priority: 100 });
263+
});
264+
265+
it.each([
266+
{
267+
label: "automatic runtime selection",
268+
requestedRuntime: "auto" as const,
269+
modelProvider: { preparedAuth: { source: "harness" as const } },
270+
},
271+
{
272+
label: "an authored endpoint",
273+
requestedRuntime: "codex" as const,
274+
modelProvider: {
275+
baseUrl: "https://relay.example.test/v1",
276+
preparedAuth: { source: "harness" as const },
277+
},
278+
},
279+
{
280+
label: "an owner-selected credential",
281+
requestedRuntime: "codex" as const,
282+
modelProvider: { preparedAuth: { source: "profile" as const, mode: "api-key" } },
283+
},
284+
])("does not infer native model access for $label", ({ requestedRuntime, modelProvider }) => {
285+
const result = harness.supports({
286+
provider: "openai",
287+
modelId: "gpt-future",
288+
requestedRuntime,
289+
modelProvider: { requestTransportOverrides: "none", ...modelProvider },
290+
});
291+
292+
expect(result.supported).toBe(false);
293+
expect(!result.supported ? result.reason : undefined).toContain("not declared");
294+
});
295+
251296
it.each([
252297
{
253298
label: "forwarded OAuth subscription",

‎extensions/codex/harness.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ export function createCodexAppServerAgentHarness(
204204
}
205205
const preparedAuth = ctx.modelProvider?.preparedAuth;
206206
const runtimePolicy = ctx.modelProvider?.runtimePolicy;
207+
// Codex owns discovery and auth for new first-party models. Only trust that
208+
// native account when no authored transport or host credential is involved.
209+
const nativeAccountOwnsUnobservedModel =
210+
provider === "openai" &&
211+
ctx.requestedRuntime === "codex" &&
212+
Boolean(ctx.modelId?.trim()) &&
213+
preparedAuth?.source === "harness" &&
214+
preparedAuth.mode === undefined &&
215+
preparedAuth.requirement === undefined &&
216+
ctx.modelProvider?.api === undefined &&
217+
ctx.modelProvider?.baseUrl === undefined &&
218+
ctx.modelProvider?.azureApiVersion === undefined &&
219+
ctx.modelProvider?.request === undefined;
207220
if (runtimePolicy) {
208221
const compatible = runtimePolicy.compatibleIds.some(
209222
(id) => id.trim().toLowerCase() === normalizedHarnessRuntimeId,
@@ -214,7 +227,7 @@ export function createCodexAppServerAgentHarness(
214227
reason: "Codex cannot reproduce the prepared provider route",
215228
};
216229
}
217-
} else if (ctx.modelProvider && provider !== "codex") {
230+
} else if (ctx.modelProvider && provider !== "codex" && !nativeAccountOwnsUnobservedModel) {
218231
return {
219232
supported: false,
220233
reason: "provider route compatibility with Codex is not declared",

0 commit comments

Comments
 (0)