Skip to content

Commit efc33f8

Browse files
authored
fix: preserve GPT-5.6 Max and Ultra through Codex (#126492)
* fix(agents): preserve GPT-5.6 thinking capabilities Carry harness-owned effort metadata from the prepared catalog to the final executable model without leaking it across model or harness changes. Preserve exact GPT-5.6 registry metadata and persisted Ultra selections across route-scoped projections. * fix(agents): resolve ambient catalog owner * test(commands): mock thinking hydration policy * fix(sessions): validate persisted thinking selections * fix(commands): persist thinking selection provenance * fix(agents): scope thinking hydration per fallback * fix(sessions): hide fallback thinking provenance
1 parent 29f8611 commit efc33f8

46 files changed

Lines changed: 1135 additions & 227 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎config/assertion-safety-baseline.txt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1811,7 +1811,7 @@ src/agents/embedded-agent-runner/compaction-hooks.ts 1
18111811
src/agents/embedded-agent-runner/compaction-session-agent.ts 7
18121812
src/agents/embedded-agent-runner/context-engine-maintenance.ts 3
18131813
src/agents/embedded-agent-runner/delivery-evidence.ts 12
1814-
src/agents/embedded-agent-runner/direct-compaction-preparation.ts 3
1814+
src/agents/embedded-agent-runner/direct-compaction-preparation.ts 1
18151815
src/agents/embedded-agent-runner/empty-assistant-turn.ts 1
18161816
src/agents/embedded-agent-runner/extensions.ts 1
18171817
src/agents/embedded-agent-runner/extra-params.ts 12
@@ -2041,7 +2041,7 @@ src/agents/sessions/model-registry.ts 13
20412041
src/agents/sessions/model-resolver.ts 1
20422042
src/agents/sessions/package-manager.ts 8
20432043
src/agents/sessions/resolve-config-value.ts 1
2044-
src/agents/sessions/sdk.ts 4
2044+
src/agents/sessions/sdk.ts 3
20452045
src/agents/sessions/session-manager-branching.ts 1
20462046
src/agents/sessions/session-manager-codec.ts 7
20472047
src/agents/sessions/session-manager-core.ts 1

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

Lines changed: 46 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,33 +1929,12 @@ describe("buildOpenAIProvider", () => {
19291929
});
19301930
});
19311931

1932-
it.each([
1933-
{
1934-
id: "gpt-5.6",
1935-
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 },
1936-
thinkingLevelMap: { off: "none", xhigh: "xhigh", max: "max" },
1937-
},
1938-
{
1939-
id: "gpt-5.6-sol",
1940-
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 },
1941-
thinkingLevelMap: { off: "none", xhigh: "xhigh", max: "max" },
1942-
},
1943-
{
1944-
id: "gpt-5.6-terra",
1945-
cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 3.125 },
1946-
thinkingLevelMap: { off: "none", xhigh: "xhigh", max: "max" },
1947-
},
1948-
{
1949-
id: "gpt-5.6-luna",
1950-
cost: { input: 1, output: 6, cacheRead: 0.1, cacheWrite: 1.25 },
1951-
thinkingLevelMap: { off: "none", xhigh: "xhigh", max: "max" },
1952-
},
1953-
])("resolves $id locally with direct API metadata", ({ id, cost, thinkingLevelMap }) => {
1932+
it("synthesizes the gpt-5.6 alias from the nearest direct API template", () => {
19541933
const provider = buildOpenAIProvider();
19551934

19561935
const model = provider.resolveDynamicModel?.({
19571936
provider: "openai",
1958-
modelId: id,
1937+
modelId: "gpt-5.6",
19591938
modelRegistry: {
19601939
find: (_provider: string, templateId: string) =>
19611940
templateId === "gpt-5.5"
@@ -1977,18 +1956,59 @@ describe("buildOpenAIProvider", () => {
19771956
} as never);
19781957

19791958
expectFields(model, {
1980-
id,
1959+
id: "gpt-5.6",
19811960
provider: "openai",
19821961
api: "openai-responses",
19831962
baseUrl: "https://api.openai.com/v1",
19841963
contextWindow: 1_050_000,
19851964
contextTokens: 272_000,
19861965
maxTokens: 128_000,
1987-
cost,
1988-
thinkingLevelMap,
1966+
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 },
1967+
thinkingLevelMap: { off: "none", xhigh: "xhigh", max: "max" },
19891968
});
19901969
});
19911970

1971+
it.each([
1972+
{
1973+
id: "gpt-5.6-sol",
1974+
cost: { input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 },
1975+
},
1976+
{
1977+
id: "gpt-5.6-terra",
1978+
cost: { input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 3.125 },
1979+
},
1980+
{
1981+
id: "gpt-5.6-luna",
1982+
cost: { input: 1, output: 6, cacheRead: 0.1, cacheWrite: 1.25 },
1983+
},
1984+
])("preserves exact registry metadata for $id", ({ id, cost }) => {
1985+
const provider = buildOpenAIProvider();
1986+
const exactModel = {
1987+
id,
1988+
name: id,
1989+
provider: "openai",
1990+
api: "openai-responses",
1991+
baseUrl: "https://api.openai.com/v1",
1992+
reasoning: true,
1993+
input: ["text", "image"],
1994+
cost,
1995+
contextWindow: 1_050_000,
1996+
contextTokens: 272_000,
1997+
maxTokens: 128_000,
1998+
compat: { supportedReasoningEfforts: ["registry-exact"] },
1999+
};
2000+
2001+
const model = provider.resolveDynamicModel?.({
2002+
provider: "openai",
2003+
modelId: id,
2004+
modelRegistry: {
2005+
find: (_provider: string, templateId: string) => (templateId === id ? exactModel : null),
2006+
} as never,
2007+
} as never);
2008+
2009+
expect(model).toBe(exactModel);
2010+
});
2011+
19922012
it("resolves gpt-5.5-pro locally", () => {
19932013
const provider = buildOpenAIProvider();
19942014

‎extensions/openai/openai-provider.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,17 @@ const OPENAI_GPT_FORWARD_COMPAT_CASES = [
875875
] satisfies Parameters<typeof resolveFamilyForwardCompatModel>[0]["cases"];
876876

877877
function resolveOpenAIGptForwardCompatModel(ctx: ProviderResolveDynamicModelContext) {
878+
const modelId = normalizeLowercaseStringOrEmpty(ctx.modelId);
879+
if (
880+
modelId === OPENAI_GPT_56_SOL_MODEL_ID ||
881+
modelId === OPENAI_GPT_56_TERRA_MODEL_ID ||
882+
modelId === OPENAI_GPT_56_LUNA_MODEL_ID
883+
) {
884+
const exactModel = ctx.modelRegistry.find(PROVIDER_ID, ctx.modelId);
885+
if (exactModel) {
886+
return exactModel;
887+
}
888+
}
878889
return resolveFamilyForwardCompatModel({
879890
providerId: PROVIDER_ID,
880891
ctx,

‎src/agents/agent-command.live-model-switch.test-helpers.ts‎

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ type ModelCatalogEntry = {
8484
provider: string;
8585
id: string;
8686
name?: string;
87+
api?: string;
88+
baseUrl?: string;
8789
reasoning?: boolean;
8890
compat?: unknown;
8991
};
@@ -112,8 +114,13 @@ export function isTestModelKeyAllowed(allowedKeys: ReadonlySet<string>, key: str
112114
}
113115

114116
export function buildTestConfiguredModelCatalog(cfg?: unknown): ModelCatalogEntry[] {
115-
const providers = (cfg as { models?: { providers?: Record<string, { models?: unknown[] }> } })
116-
?.models?.providers;
117+
const providers = (
118+
cfg as {
119+
models?: {
120+
providers?: Record<string, { api?: unknown; baseUrl?: unknown; models?: unknown[] }>;
121+
};
122+
}
123+
)?.models?.providers;
117124
if (!providers) {
118125
return [];
119126
}
@@ -130,6 +137,18 @@ export function buildTestConfiguredModelCatalog(cfg?: unknown): ModelCatalogEntr
130137
provider,
131138
id,
132139
name: typeof model.name === "string" ? model.name : id,
140+
api:
141+
typeof model.api === "string"
142+
? model.api
143+
: typeof entry.api === "string"
144+
? entry.api
145+
: undefined,
146+
baseUrl:
147+
typeof model.baseUrl === "string"
148+
? model.baseUrl
149+
: typeof entry.baseUrl === "string"
150+
? entry.baseUrl
151+
: undefined,
133152
reasoning: typeof model.reasoning === "boolean" ? model.reasoning : undefined,
134153
compat: model.compat,
135154
};

‎src/agents/agent-command.live-model-switch.test.ts‎

Lines changed: 154 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ const state = vi.hoisted(() => ({
113113
isThinkingLevelSupportedMock: vi.fn((_args: unknown) => true),
114114
resolveSupportedThinkingLevelMock: vi.fn(({ level }: { level?: string }) => level),
115115
resolveThinkingDefaultMock: vi.fn((_args: unknown) => "low"),
116-
loadManifestModelCatalogMock: vi.fn(() => []),
116+
loadManifestModelCatalogMock: vi.fn((): ModelCatalogSnapshot["entries"] => []),
117117
manifestMetadataSnapshot: { plugins: [] },
118118
resolvePluginMetadataSnapshotMock: vi.fn(),
119119
listSkillCommandsForWorkspaceMock: vi.fn((_params: unknown) => []),
@@ -2509,6 +2509,12 @@ describe("agentCommand – LiveSessionModelSwitchError retry", () => {
25092509
return entry?.thinkingLevel === "medium";
25102510
})?.[0] as { entry?: Record<string, unknown> } | undefined;
25112511
expect(touchWrite?.entry?.lastInteractionAt).toBeDefined();
2512+
expectRecordFields(touchWrite?.entry?.thinkingLevelSelection, {
2513+
provider: "anthropic",
2514+
model: "claude",
2515+
agentRuntime: "openclaw",
2516+
level: "medium",
2517+
});
25122518
expect(state.updateSessionStoreAfterAgentRunMock).toHaveBeenCalledTimes(1);
25132519
});
25142520

@@ -2709,6 +2715,84 @@ describe("agentCommand – LiveSessionModelSwitchError retry", () => {
27092715
expect(state.loadFullModelCatalogMock).not.toHaveBeenCalled();
27102716
});
27112717

2718+
it("keeps later provider capability metadata after hydrating a Codex primary", async () => {
2719+
state.runtimeConfigMock = {
2720+
agents: {
2721+
defaults: {
2722+
model: { primary: "openai/gpt-5.6-sol" },
2723+
models: {
2724+
"openai/gpt-5.6-sol": { agentRuntime: { id: "codex" } },
2725+
"gmn/gpt-5.4": { agentRuntime: { id: "openclaw" } },
2726+
},
2727+
},
2728+
},
2729+
};
2730+
state.loadManifestModelCatalogMock.mockReturnValue([
2731+
{
2732+
provider: "openai",
2733+
id: "gpt-5.6-sol",
2734+
name: "GPT 5.6 Sol",
2735+
reasoning: true,
2736+
compat: { supportedReasoningEfforts: ["max"] },
2737+
},
2738+
{
2739+
provider: "gmn",
2740+
id: "gpt-5.4",
2741+
name: "GPT 5.4 via GMN",
2742+
reasoning: true,
2743+
compat: { supportedReasoningEfforts: ["low", "medium", "high", "xhigh"] },
2744+
},
2745+
]);
2746+
state.loadProviderScopedThinkingCatalogMock.mockImplementation(async (params: unknown) => {
2747+
const { provider } = params as { provider?: string };
2748+
if (provider !== "openai") {
2749+
throw new Error(`unexpected scoped thinking hydration for ${provider}`);
2750+
}
2751+
return [
2752+
{
2753+
provider: "openai",
2754+
id: "gpt-5.6-sol",
2755+
name: "GPT 5.6 Sol",
2756+
reasoning: true,
2757+
compat: { supportedReasoningEfforts: ["max", "ultra"] },
2758+
},
2759+
];
2760+
});
2761+
state.resolveThinkingDefaultMock.mockImplementation((args: unknown) => {
2762+
const { provider, catalog } = args as {
2763+
provider?: string;
2764+
catalog?: Array<{ provider: string; id: string }>;
2765+
};
2766+
if (provider === "gmn") {
2767+
expect(catalog).toContainEqual(expect.objectContaining({ provider: "gmn", id: "gpt-5.4" }));
2768+
return "xhigh";
2769+
}
2770+
return "ultra";
2771+
});
2772+
state.runWithModelFallbackMock.mockImplementation(async (params: FallbackRunnerParams) => {
2773+
await params.run(params.provider, params.model);
2774+
const result = await params.run("gmn", "gpt-5.4");
2775+
return { result, provider: "gmn", model: "gpt-5.4", attempts: [] };
2776+
});
2777+
state.runAgentAttemptMock.mockImplementation(
2778+
async (params: { providerOverride: string; modelOverride: string }) =>
2779+
makeSuccessResult(params.providerOverride, params.modelOverride),
2780+
);
2781+
2782+
await runBasicAgentCommand();
2783+
2784+
expectRecordFields(mockCallArg(state.runAgentAttemptMock, 0), {
2785+
modelOverride: "gpt-5.6-sol",
2786+
resolvedThinkLevel: "ultra",
2787+
});
2788+
expectRecordFields(mockCallArg(state.runAgentAttemptMock, 1), {
2789+
providerOverride: "gmn",
2790+
modelOverride: "gpt-5.4",
2791+
resolvedThinkLevel: "xhigh",
2792+
});
2793+
expect(state.loadProviderScopedThinkingCatalogMock).toHaveBeenCalledTimes(1);
2794+
});
2795+
27122796
it("persists and clears current run delivery context for restart recovery", async () => {
27132797
setupSingleAttemptFallback();
27142798
state.runAgentAttemptMock.mockResolvedValue(makeSuccessResult("openai", "gpt-5.4"));
@@ -3722,6 +3806,75 @@ describe("agentCommand – LiveSessionModelSwitchError retry", () => {
37223806
expect(lifecycleFinishingCalls).toHaveLength(1);
37233807
});
37243808

3809+
it("forwards harness-augmented GPT-5.6 thinking capability to the attempt", async () => {
3810+
const modelId = "gpt-5.6-sol";
3811+
const modelKey = `openai/${modelId}`;
3812+
const providerReasoningEfforts = ["low", "medium", "high", "xhigh", "max"];
3813+
const harnessReasoningEfforts = [...providerReasoningEfforts, "ultra"];
3814+
state.runtimeConfigMock = {
3815+
agents: {
3816+
defaults: {
3817+
model: { primary: modelKey },
3818+
models: { [modelKey]: { agentRuntime: { id: "codex" } } },
3819+
},
3820+
},
3821+
models: {
3822+
providers: {
3823+
openai: {
3824+
api: "openai-responses",
3825+
baseUrl: "https://api.openai.com/v1",
3826+
models: [],
3827+
},
3828+
},
3829+
},
3830+
};
3831+
state.loadManifestModelCatalogMock.mockReturnValue([
3832+
{
3833+
provider: "openai",
3834+
id: modelId,
3835+
name: modelId,
3836+
api: "openai-responses",
3837+
baseUrl: "https://api.openai.com/v1",
3838+
reasoning: true,
3839+
compat: {
3840+
thinkingFormat: "openai",
3841+
supportedReasoningEfforts: providerReasoningEfforts,
3842+
},
3843+
},
3844+
]);
3845+
state.loadProviderScopedThinkingCatalogMock.mockResolvedValue([
3846+
{
3847+
provider: "openai",
3848+
id: modelId,
3849+
name: modelId,
3850+
api: "openai-chatgpt-responses",
3851+
baseUrl: "https://chatgpt.com/backend-api/codex",
3852+
reasoning: true,
3853+
compat: {
3854+
thinkingFormat: "openai",
3855+
supportedReasoningEfforts: harnessReasoningEfforts,
3856+
},
3857+
},
3858+
]);
3859+
setupSuccessfulAttempt("openai", modelId);
3860+
3861+
await agentCommand({ message: "hello", to: "+1234567890", thinking: "ultra" });
3862+
3863+
expectRecordFields(mockCallArg(state.runAgentAttemptMock), {
3864+
modelOverride: modelId,
3865+
resolvedThinkLevel: "ultra",
3866+
modelThinkingCapability: {
3867+
provider: "openai",
3868+
modelId,
3869+
agentRuntime: "codex",
3870+
compat: {
3871+
thinkingFormat: "openai",
3872+
supportedReasoningEfforts: harnessReasoningEfforts,
3873+
},
3874+
},
3875+
});
3876+
});
3877+
37253878
it.each([
37263879
{
37273880
name: "validates explicit thinking against configured model compat without an allowlist",

0 commit comments

Comments
 (0)