Skip to content

Commit b2de68f

Browse files
authored
Carry native Codex account-model support into the pinned release (#127395)
* Let Codex run newly available account models without host credentials * Keep authored provider routes ahead of native account authentication * Keep native Codex account discovery consistent with model availability * Preserve advanced reasoning for newly discovered Codex models
1 parent 0e374f8 commit b2de68f

11 files changed

Lines changed: 171 additions & 4 deletions

‎extensions/codex/harness.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,17 @@ describe("Codex agent harness supports()", () => {
133133
).toEqual({ supported: true, priority: 100 });
134134
});
135135

136+
it("lets explicit Codex model discovery run before auth has been prepared", () => {
137+
expect(
138+
harness.supports({
139+
provider: "openai",
140+
modelId: "gpt-future",
141+
requestedRuntime: "codex",
142+
modelProvider: { requestTransportOverrides: "none" },
143+
}),
144+
).toEqual({ supported: true, priority: 100 });
145+
});
146+
136147
it.each([
137148
{
138149
label: "automatic runtime selection",

‎extensions/codex/harness.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ export function createCodexAppServerAgentHarness(options: {
141141
provider === "openai" &&
142142
ctx.requestedRuntime === "codex" &&
143143
Boolean(ctx.modelId?.trim()) &&
144-
preparedAuth?.source === "harness" &&
145-
preparedAuth.mode === undefined &&
146-
preparedAuth.requirement === undefined &&
144+
(preparedAuth === undefined || preparedAuth.source === "harness") &&
145+
preparedAuth?.mode === undefined &&
146+
preparedAuth?.requirement === undefined &&
147147
ctx.modelProvider?.api === undefined &&
148148
ctx.modelProvider?.baseUrl === undefined &&
149149
ctx.modelProvider?.azureApiVersion === undefined &&

‎extensions/openai/openai-chatgpt-provider.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,25 @@ function resolveCodexForwardCompatModel(ctx: ProviderResolveDynamicModelContext)
333333
maxTokens: OPENAI_CODEX_GPT_54_MAX_TOKENS,
334334
cost: OPENAI_CODEX_GPT_54_MINI_COST,
335335
};
336+
} else if (
337+
ctx.agentRuntimeId === "codex" &&
338+
ctx.authProfileId === undefined &&
339+
ctx.authProfileMode === undefined &&
340+
ctx.providerConfig?.auth === undefined
341+
) {
342+
// Codex owns its account-scoped model catalog. When that catalog is not yet
343+
// available, keep the requested identity intact and let the native runtime
344+
// decide whether the account can actually use it.
345+
templateIds = OPENAI_CODEX_GPT_56_MODEL_IDS;
346+
patch = {
347+
reasoning: true,
348+
input: ["text", "image"],
349+
thinkingLevelMap: OPENAI_CODEX_GPT_56_THINKING_LEVEL_MAP,
350+
compat: {
351+
supportsReasoningEffort: true,
352+
supportedReasoningEfforts: ["low", "medium", "high", "xhigh", "max"],
353+
},
354+
};
336355
} else {
337356
return undefined;
338357
}
@@ -371,6 +390,8 @@ function resolveCodexForwardCompatModel(ctx: ProviderResolveDynamicModelContext)
371390
contextWindow: patch?.contextWindow ?? DEFAULT_CONTEXT_TOKENS,
372391
contextTokens: patch?.contextTokens,
373392
maxTokens: patch?.maxTokens ?? DEFAULT_CONTEXT_TOKENS,
393+
...(patch?.thinkingLevelMap ? { thinkingLevelMap: patch.thinkingLevelMap } : {}),
394+
...(patch?.compat ? { compat: patch.compat } : {}),
374395
} as ProviderRuntimeModel)
375396
);
376397
}

‎extensions/openai/openai-provider.test.ts‎

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,6 +1723,74 @@ describe("buildOpenAIProvider", () => {
17231723
).toEqual({ effort: "high", transport: "sse" });
17241724
});
17251725

1726+
it("delegates an unlisted first-party model to its explicitly selected Codex runtime", () => {
1727+
const provider = buildOpenAIProvider();
1728+
const model = provider.resolveDynamicModel?.({
1729+
provider: "openai",
1730+
modelId: "gpt-future",
1731+
modelRegistry: { find: () => null },
1732+
agentRuntimeId: "codex",
1733+
} as never);
1734+
1735+
expect(model).toMatchObject({
1736+
provider: "openai",
1737+
id: "gpt-future",
1738+
api: "openai-chatgpt-responses",
1739+
baseUrl: "https://chatgpt.com/backend-api/codex",
1740+
compat: { supportedReasoningEfforts: ["low", "medium", "high", "xhigh", "max"] },
1741+
});
1742+
expect(
1743+
provider
1744+
.resolveThinkingProfile?.({
1745+
provider: "openai",
1746+
modelId: "gpt-future",
1747+
agentRuntime: "codex",
1748+
api: model?.api,
1749+
compat: model?.compat,
1750+
} as never)
1751+
?.levels.map((level) => level.id),
1752+
).toContain("max");
1753+
expect(
1754+
provider
1755+
.resolveThinkingProfile?.({
1756+
provider: "openai",
1757+
modelId: "gpt-future",
1758+
agentRuntime: "codex",
1759+
} as never)
1760+
?.levels.map((level) => level.id),
1761+
).toEqual(expect.arrayContaining(["xhigh", "max"]));
1762+
});
1763+
1764+
it("does not invent an unlisted model for authored Platform credentials", () => {
1765+
const provider = buildOpenAIProvider();
1766+
1767+
expect(
1768+
provider.resolveDynamicModel?.({
1769+
provider: "openai",
1770+
modelId: "gpt-future",
1771+
modelRegistry: { find: () => null },
1772+
agentRuntimeId: "codex",
1773+
authProfileId: "openai:platform",
1774+
authProfileMode: "api_key",
1775+
providerConfig: {
1776+
auth: "api-key",
1777+
api: "openai-responses",
1778+
baseUrl: "https://api.openai.com/v1",
1779+
},
1780+
} as never),
1781+
).toBeUndefined();
1782+
expect(
1783+
provider
1784+
.resolveThinkingProfile?.({
1785+
provider: "openai",
1786+
modelId: "gpt-future",
1787+
agentRuntime: "codex",
1788+
api: "openai-responses",
1789+
} as never)
1790+
?.levels.map((level) => level.id),
1791+
).not.toContain("max");
1792+
});
1793+
17261794
it("restores gpt-5.3-codex-spark only through ChatGPT/Codex OAuth routing", () => {
17271795
const provider = buildOpenAIProvider();
17281796

‎extensions/openai/thinking-policy.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ function buildOpenAIThinkingProfile(params: {
110110
(agentRuntime === "openclaw" ||
111111
agentRuntime === "auto" ||
112112
(agentRuntime === "codex" && codexSupportsUltra));
113+
const nativeCodexNeedsAccountEffortValidation =
114+
agentRuntime === "codex" &&
115+
params.compat?.supportedReasoningEfforts === undefined &&
116+
(params.api === undefined || params.api === "openai-chatgpt-responses") &&
117+
!matchesExactOrPrefix(params.modelId, params.xhighModelIds) &&
118+
!modelId.startsWith("gpt-5.6");
113119
const defaultLevel = isSol || isTerra || isLuna ? "medium" : undefined;
114120
const fallbackLevels: ProviderThinkingProfile["levels"] = [
115121
...OPENAI_THINKING_BASE_LEVELS,
@@ -118,6 +124,9 @@ function buildOpenAIThinkingProfile(params: {
118124
: []),
119125
...(supportsMax ? [{ id: "max" as const }] : []),
120126
...(supportsUltra ? [{ id: "ultra" as const }] : []),
127+
...(nativeCodexNeedsAccountEffortValidation
128+
? [{ id: "xhigh" as const }, { id: "max" as const }]
129+
: []),
121130
];
122131
const levels =
123132
agentRuntime === "codex" && authoritativeCodexEfforts !== undefined

‎src/agents/model-auth-availability.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,15 @@ describe("createModelAuthAvailabilityResolver", () => {
657657
expect(result).not.toHaveProperty("selectedRoute");
658658
});
659659

660+
it("keeps one unconfigured Codex route indeterminate until native account validation", () => {
661+
expect(
662+
evaluate({
663+
resolution: { ...dualRoutes, routes: [subscriptionRoute] },
664+
syntheticAuthProviderRefs: ["codex"],
665+
}),
666+
).toMatchObject({ availability: undefined, evidence: "synthetic" });
667+
});
668+
660669
it("does not let invalid automatic profile evidence block synthetic Codex ownership", () => {
661670
expect(
662671
evaluate({

‎src/agents/model-auth-availability.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,10 @@ export function createModelAuthAvailabilityResolver(
940940
sourcePlan,
941941
configuredAuthMode: automaticRouteAuthMode,
942942
...(syntheticCodexOwnsAuth ? { runtimeAuthOwner: { id: "codex" } } : {}),
943+
...(syntheticCodexOwnsAuth &&
944+
resolveMergedModelProviderConfig(params.cfg, provider) === undefined
945+
? { allowNativeAuthOnSingleRoute: true }
946+
: {}),
943947
});
944948
if (routeAuthDecision.kind === "deferred" && syntheticCodexOwnsAuth) {
945949
return { availability: undefined, routeResolution, evidence: "synthetic" };

‎src/agents/openai-model-routes.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export function selectOpenAIModelRouteAuth(params: {
5858
sourcePlan: ProviderModelAuthSourcePlan;
5959
configuredAuthMode?: string;
6060
runtimeAuthOwner?: { id: string };
61+
allowNativeAuthOnSingleRoute?: boolean;
6162
}) {
6263
return selectProviderModelRouteAuth({ provider: OPENAI_PROVIDER_ID, ...params });
6364
}

‎src/agents/provider-model-route-auth.test.ts‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,36 @@ describe("provider model route auth", () => {
331331
});
332332
});
333333

334+
it("lets an explicit native owner authenticate its sole compatible route", () => {
335+
expect(
336+
selectProviderModelRouteAuth({
337+
provider: "openai",
338+
resolution: { ...routes, routes: [routes.routes[1]] },
339+
runtimeAuthOwner: { id: "codex" },
340+
allowNativeAuthOnSingleRoute: true,
341+
sourcePlan: buildProviderModelAuthSourcePlan({ profiles: [] }),
342+
}),
343+
).toEqual({
344+
kind: "deferred",
345+
reason: "runtime-auth-owner",
346+
routeSupport: {
347+
requestTransportOverrides: "none",
348+
runtimePolicy: { compatibleIds: ["openclaw", "codex"] },
349+
},
350+
});
351+
});
352+
353+
it("does not infer native ownership for an explicitly authored single route", () => {
354+
expect(
355+
selectProviderModelRouteAuth({
356+
provider: "openai",
357+
resolution: { ...routes, routes: [routes.routes[1]] },
358+
runtimeAuthOwner: { id: "codex" },
359+
sourcePlan: buildProviderModelAuthSourcePlan({ profiles: [] }),
360+
}),
361+
).toMatchObject({ kind: "rejected", reason: "configured-auth" });
362+
});
363+
334364
it.each([
335365
["Platform", routes.routes[0], profile("openai:chatgpt", "oauth", "ready")],
336366
["subscription", routes.routes[1], profile("openai:platform", "api_key", "ready")],

‎src/agents/provider-model-route-auth.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ export function selectProviderModelRouteAuth(params: {
269269
configuredAuthMode?: string;
270270
/** Explicit native auth owner allowed to defer an otherwise unowned route. */
271271
runtimeAuthOwner?: { id: string };
272+
/** True only when no provider transport or credentials were authored. */
273+
allowNativeAuthOnSingleRoute?: boolean;
272274
}): ProviderModelRouteAuthDecision {
273275
const requiredProfile =
274276
params.sourcePlan.kind === "required" && params.sourcePlan.source.kind === "profile"
@@ -392,7 +394,16 @@ export function selectProviderModelRouteAuth(params: {
392394
const runtimeAuthOwnerIsCompatible =
393395
Boolean(normalizedRuntimeAuthOwner) &&
394396
routeSupport.runtimePolicy.compatibleIds.includes(normalizedRuntimeAuthOwner ?? "");
395-
if (params.resolution.routes.length > 1 && runtimeAuthOwnerIsCompatible && !configuredRoute) {
397+
const hostHasNoCredentialToHonor =
398+
params.allowNativeAuthOnSingleRoute === true &&
399+
params.sourcePlan.kind === "automatic" &&
400+
params.sourcePlan.orderedProfiles.length === 0 &&
401+
params.sourcePlan.fallback === undefined;
402+
if (
403+
runtimeAuthOwnerIsCompatible &&
404+
!configuredRoute &&
405+
(params.resolution.routes.length > 1 || hostHasNoCredentialToHonor)
406+
) {
396407
return { kind: "deferred", reason: "runtime-auth-owner", routeSupport };
397408
}
398409
return reject(

0 commit comments

Comments
 (0)