Skip to content

Commit efdc051

Browse files
committed
feat(codex): expose account-specific Daybreak access programs
Offer the access programs advertised for each Codex model so GPT-6 Sol can request Daybreak Blue without relying on the rolling model alias. Automatic omits the override; explicit choices retain the model ID. Forward selections through chat, plan mode, monitor continuations, text generation, and image evaluation. Refresh managed account choices from the account catalog and keep them out of custom-model fallbacks. Validate with focused protocol and provider tests, scoped typechecks, and browser checks for selection persistence. Two independent Sol xhigh review rounds resolved custom-model and text-generation gaps. Implemented with GPT-6-Astra through the Codex harness.
1 parent e7ed080 commit efdc051

15 files changed

Lines changed: 453 additions & 23 deletions

‎apps/server/src/codexModelOptions.test.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ it.each(["gpt-6-astra", "openai.gpt-6-astra"])(
2424
model: "gpt-6-astra",
2525
effort: "max",
2626
serviceTier: null,
27+
cyberAccessProgram: null,
2728
});
2829
assert.equal(resolveCodexModelSettings(createModelSelection(instanceId, model)).model, model);
2930
assert.equal(

‎apps/server/src/codexModelOptions.ts‎

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,74 @@
1-
import { DEFAULT_MODEL, type ModelSelection } from "@t3tools/contracts";
1+
import {
2+
DEFAULT_MODEL,
3+
type ModelSelection,
4+
type ProviderOptionDescriptor,
5+
} from "@t3tools/contracts";
26
import {
37
codexModelFamily,
48
normalizeModelSlug,
59
getModelSelectionBooleanOptionValue,
610
getModelSelectionStringOptionValue,
711
} from "@t3tools/shared/model";
12+
import * as Schema from "effect/Schema";
13+
import * as CodexSchema from "effect-codex-app-server/schema";
814

915
export const DEFAULT_CODEX_REASONING_EFFORT = "max";
1016

17+
export const decodeCodexCyberAccessProgram = Schema.decodeUnknownEffect(
18+
Schema.NullOr(CodexSchema.V2TurnStartParams__CyberAccessProgram),
19+
);
20+
21+
export function codexAccessProgramOptionDescriptors(
22+
programs: ReadonlyArray<string> | null | undefined,
23+
): ReadonlyArray<ProviderOptionDescriptor> {
24+
if (!programs?.some((program) => program === "daybreakBlue" || program === "daybreakRed")) {
25+
return [];
26+
}
27+
return [
28+
{
29+
id: "cyberAccessProgram",
30+
label: "Access program",
31+
type: "select",
32+
currentValue: "automatic",
33+
options: [
34+
{
35+
id: "automatic",
36+
label: "Automatic",
37+
description: "Let Codex choose based on your account and model.",
38+
isDefault: true,
39+
},
40+
...[
41+
{ id: "standard", label: "Standard" },
42+
{ id: "daybreakBlue", label: "Daybreak Blue" },
43+
{ id: "daybreakRed", label: "Daybreak Red" },
44+
].filter((option) => programs.includes(option.id)),
45+
],
46+
},
47+
];
48+
}
49+
1150
export interface CodexModelSettings {
1251
readonly model: string;
1352
readonly effort: string | null;
1453
readonly serviceTier: string | null;
54+
readonly cyberAccessProgram: string | null;
1555
}
1656

1757
export function resolveCodexModelSettings(
1858
modelSelection?: ModelSelection | null,
1959
): CodexModelSettings {
2060
const model = normalizeModelSlug(modelSelection?.model) ?? DEFAULT_MODEL;
61+
const cyberAccessProgram = getModelSelectionStringOptionValue(
62+
modelSelection,
63+
"cyberAccessProgram",
64+
);
2165
return {
2266
model,
2367
effort:
2468
getModelSelectionStringOptionValue(modelSelection, "reasoningEffort") ??
2569
(codexModelFamily(model) === DEFAULT_MODEL ? DEFAULT_CODEX_REASONING_EFFORT : null),
2670
serviceTier: getCodexServiceTierOptionValue(modelSelection) ?? null,
71+
cyberAccessProgram: cyberAccessProgram === "automatic" ? null : (cyberAccessProgram ?? null),
2772
};
2873
}
2974

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.test.ts‎

Lines changed: 54 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,48 @@ describe("CodexAdapterV2 assistant message streaming", () => {
398398
});
399399

400400
describe("CodexAdapterV2 runtime policy", () => {
401+
it.effect.each(["default", "plan"] as const)(
402+
"requests explicit cyber access programs and restores automatic behavior in %s mode",
403+
(interactionMode) =>
404+
Effect.gen(function* () {
405+
for (const program of ["daybreakBlue", "standard", "daybreakRed", "automatic", undefined]) {
406+
const params = yield* CodexAdapterV2.buildCodexTurnStartParams({
407+
nativeThreadId: "cyber-access-thread",
408+
codexInput: [{ type: "text", text: "Review this patch" }],
409+
runtimePolicy: { runtimeMode: "auto", interactionMode, cwd: null },
410+
modelSelection: {
411+
instanceId: ProviderInstanceId.make("codex"),
412+
model: "gpt-6-sol",
413+
options: program === undefined ? [] : [{ id: "cyberAccessProgram", value: program }],
414+
},
415+
omitServiceTier: true,
416+
});
417+
assert.equal(params.model, "gpt-6-sol");
418+
if (program === "automatic" || program === undefined)
419+
assert.notProperty(params, "cyberAccessProgram");
420+
else assert.equal(params.cyberAccessProgram, program);
421+
}
422+
}),
423+
);
424+
425+
it.effect("rejects an invalid cyber access program instead of silently using automatic", () =>
426+
Effect.gen(function* () {
427+
const error = yield* Effect.flip(
428+
CodexAdapterV2.buildCodexTurnStartParams({
429+
nativeThreadId: "cyber-access-thread",
430+
codexInput: [],
431+
runtimePolicy: { runtimeMode: "auto", interactionMode: "default", cwd: null },
432+
modelSelection: {
433+
instanceId: ProviderInstanceId.make("codex"),
434+
model: "gpt-6-sol",
435+
options: [{ id: "cyberAccessProgram", value: "invalid-program" }],
436+
},
437+
}),
438+
);
439+
assert.equal(error._tag, "SchemaError");
440+
}),
441+
);
442+
401443
it.effect("sends Max for Astra by default and preserves an explicit effort", () =>
402444
Effect.gen(function* () {
403445
for (const selectedEffort of [undefined, "low"]) {
@@ -3559,16 +3601,21 @@ describe("CodexAdapterV2 post-settle continuation", () => {
35593601
),
35603602
);
35613603

3562-
it.effect("restores app context after compaction without retaining monitor output", () =>
3604+
it.effect("restores app context and preserves Daybreak access during monitor delivery", () =>
35633605
Effect.scoped(
35643606
Effect.gen(function* () {
35653607
const nativeThreadId = "context-thread";
35663608
const nativeTurnId = "context-turn";
3609+
const cyberAccessProgram = "daybreakBlue";
3610+
const modelSelection = {
3611+
...CODEX_TEST_MODEL_SELECTION,
3612+
options: [{ id: "cyberAccessProgram", value: cyberAccessProgram }],
3613+
};
35673614
const params = yield* CodexAdapterV2.buildCodexTurnStartParams({
35683615
nativeThreadId,
35693616
codexInput: [{ type: "text", text: "work" }],
35703617
runtimePolicy: CODEX_TEST_RUNTIME_POLICY,
3571-
modelSelection: CODEX_TEST_MODEL_SELECTION,
3618+
modelSelection,
35723619
hasT3Mcp: true,
35733620
});
35743621
assert.include(
@@ -3599,6 +3646,7 @@ describe("CodexAdapterV2 post-settle continuation", () => {
35993646
threadId: nativeThreadId,
36003647
input: [],
36013648
additionalContext: params.additionalContext,
3649+
cyberAccessProgram,
36023650
toolOutput: {
36033651
namespace: "t3_code",
36043652
name: "monitor",
@@ -3667,15 +3715,16 @@ describe("CodexAdapterV2 post-settle continuation", () => {
36673715
authorizationHeader: "Bearer test",
36683716
browserToolsAvailable: true,
36693717
});
3670-
yield* harness.runtime.startTurn(
3671-
makeCodexTestTurnInput({
3718+
yield* harness.runtime.startTurn({
3719+
...makeCodexTestTurnInput({
36723720
threadId: harness.threadId,
36733721
providerThread: harness.providerThread,
36743722
now: yield* DateTime.now,
36753723
attemptId: RunAttemptId.make("context-attempt"),
36763724
text: "work",
36773725
}),
3678-
);
3726+
modelSelection,
3727+
});
36793728
yield* harness.runtime.steerTurn({
36803729
threadId: harness.threadId,
36813730
runId: RunId.make("run-unused"),

‎apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,10 @@ import * as Stream from "effect/Stream";
9494
import { ChildProcess, ChildProcessSpawner } from "effect/process";
9595

9696
import { resolveAttachmentPath, resolveAttachmentPathById } from "../../attachmentStore.ts";
97-
import { resolveCodexModelSettings } from "../../codexModelOptions.ts";
97+
import {
98+
decodeCodexCyberAccessProgram,
99+
resolveCodexModelSettings,
100+
} from "../../codexModelOptions.ts";
98101
import { ServerConfig } from "../../config.ts";
99102
import { expandHomePath } from "@t3tools/provider-core/server/pathExpansion";
100103
import { buildCodexApplicationContext } from "../../provider/CodexDeveloperInstructions.ts";
@@ -659,6 +662,7 @@ const decodeTurnReasoningEffort = Schema.decodeUnknownEffect(
659662
const CodexTurnStartParamsWithCollaborationMode = CodexSchema.V2TurnStartParams.pipe(
660663
Schema.fieldsAssign({
661664
collaborationMode: Schema.optionalKey(CodexSchema.ClientRequest__CollaborationMode),
665+
cyberAccessProgram: Schema.optionalKey(CodexSchema.V2TurnStartParams__CyberAccessProgram),
662666
additionalContext: Schema.optionalKey(
663667
Schema.Record(Schema.String, CodexSchema.V2TurnStartParams__AdditionalContextEntry),
664668
),
@@ -769,6 +773,9 @@ export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTur
769773
const effort =
770774
selectedEffort === undefined ? undefined : yield* decodeTurnReasoningEffort(selectedEffort);
771775
const serviceTier = input.omitServiceTier === true ? undefined : modelSettings.serviceTier;
776+
const cyberAccessProgram = yield* decodeCodexCyberAccessProgram(
777+
modelSettings.cyberAccessProgram,
778+
);
772779
// An app's context is text an MCP server wrote, so it goes in as untrusted
773780
// context: Codex renders it as quoted user-side input, never as developer
774781
// instructions.
@@ -818,6 +825,7 @@ export const buildCodexTurnStartParams = Effect.fn("CodexAdapterV2.buildCodexTur
818825
...(sandboxPolicy === undefined ? {} : { sandboxPolicy }),
819826
effort: effort ?? null,
820827
...(serviceTier === undefined ? {} : { serviceTier }),
828+
...(cyberAccessProgram === null ? {} : { cyberAccessProgram }),
821829
...(collaborationMode === undefined ? {} : { collaborationMode }),
822830
});
823831
},
@@ -7027,12 +7035,16 @@ export const makeCodexAdapterV2 = Effect.fn("makeCodexAdapterV2")(function* (
70277035
const additionalContext = (yield* Ref.get(additionalContextByThread)).get(
70287036
threadId,
70297037
);
7038+
const cyberAccessProgram = yield* decodeCodexCyberAccessProgram(
7039+
resolveCodexModelSettings(activeTurn.input.modelSelection).cyberAccessProgram,
7040+
);
70307041
const started = yield* client
70317042
.request("turn/start", {
70327043
threadId,
70337044
input: [],
70347045
toolOutput: codexMonitorToolOutput(codexInput),
70357046
...(additionalContext === undefined ? {} : { additionalContext }),
7047+
...(cyberAccessProgram === null ? {} : { cyberAccessProgram }),
70367048
})
70377049
.pipe(
70387050
Effect.map((response) => ({

‎apps/server/src/provider/CodexChatGptModels.test.ts‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { assert, it } from "@effect/vitest";
22
import * as Effect from "effect/Effect";
33
import { HttpClient, HttpClientResponse } from "effect/http";
44
import { chatGptModels } from "./CodexChatGptModels.ts";
5+
import { codexAccessProgramOptionDescriptors } from "../codexModelOptions.ts";
56

67
it.effect(
78
"uses each selected profile's token and the server's visible catalog order and names",
@@ -72,3 +73,77 @@ it.effect("does not present a cached catalog as account entitlements when discov
7273
assert.strictEqual(error._tag, "ChatGptCatalogError");
7374
}),
7475
);
76+
77+
it.effect("uses fresh account access programs instead of cached native entitlements", () =>
78+
Effect.gen(function* () {
79+
const http = HttpClient.make((request) =>
80+
Effect.succeed(
81+
HttpClientResponse.fromWeb(
82+
request,
83+
new Response(
84+
JSON.stringify({
85+
models: [
86+
{
87+
slug: "blue",
88+
display_name: "Blue eligible",
89+
visibility: "list",
90+
available_access_programs: { cyber: ["standard", "daybreak_blue"] },
91+
},
92+
{
93+
slug: "red",
94+
display_name: "Red eligible",
95+
visibility: "list",
96+
available_access_programs: { cyber: ["daybreak_red"] },
97+
},
98+
{
99+
slug: "standard",
100+
display_name: "Standard only",
101+
visibility: "list",
102+
available_access_programs: { cyber: ["standard"] },
103+
},
104+
{ slug: "missing", display_name: "Unspecified", visibility: "list" },
105+
{
106+
slug: "null",
107+
display_name: "Null",
108+
visibility: "list",
109+
available_access_programs: null,
110+
},
111+
],
112+
}),
113+
),
114+
),
115+
),
116+
);
117+
const cached = ["blue", "standard", "missing", "null"].map((slug) => ({
118+
slug,
119+
name: slug,
120+
isCustom: false,
121+
capabilities: {
122+
optionDescriptors: codexAccessProgramOptionDescriptors(["standard", "daybreakRed"]),
123+
promptCache: { minimumLifetimeMs: 300_000, source: "provider-documented" as const },
124+
},
125+
}));
126+
const models = yield* chatGptModels("account", cached).pipe(
127+
Effect.provideService(HttpClient.HttpClient, http),
128+
);
129+
assert.deepEqual(
130+
models.map((model) => {
131+
const descriptor = model.capabilities?.optionDescriptors?.find(
132+
(option) => option.id === "cyberAccessProgram",
133+
);
134+
return [
135+
model.slug,
136+
descriptor?.type === "select" ? descriptor.options.map((choice) => choice.id) : [],
137+
];
138+
}),
139+
[
140+
["blue", ["automatic", "standard", "daybreakBlue"]],
141+
["red", ["automatic", "daybreakRed"]],
142+
["standard", []],
143+
["missing", []],
144+
["null", []],
145+
],
146+
);
147+
assert.deepEqual(models[0]?.capabilities?.promptCache, cached[0]?.capabilities.promptCache);
148+
}),
149+
);

‎apps/server/src/provider/CodexChatGptModels.ts‎

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { ServerProviderModel } from "@t3tools/contracts";
22
import * as Effect from "effect/Effect";
33
import * as Schema from "effect/Schema";
44
import { HttpClient, HttpClientRequest } from "effect/http";
5+
import { codexAccessProgramOptionDescriptors } from "../codexModelOptions.ts";
56

67
export class ChatGptCatalogError extends Schema.TaggedError<ChatGptCatalogError>()(
78
"ChatGptCatalogError",
@@ -14,6 +15,9 @@ const Catalog = Schema.Struct({
1415
slug: Schema.NonEmptyString,
1516
display_name: Schema.NonEmptyString,
1617
visibility: Schema.String,
18+
available_access_programs: Schema.optional(
19+
Schema.NullOr(Schema.Struct({ cyber: Schema.Array(Schema.String) })),
20+
),
1721
}),
1822
),
1923
});
@@ -32,15 +36,35 @@ export const chatGptModels = Effect.fn("chatGptModels")(function* (
3236
const catalog = yield* response.json.pipe(Effect.flatMap(Schema.decodeUnknownEffect(Catalog)));
3337
return catalog.models
3438
.filter((model) => model.visibility === "list")
35-
.map(
36-
(model) =>
37-
({
38-
...nativeModels.find((native) => native.slug === model.slug),
39-
capabilities:
40-
nativeModels.find((native) => native.slug === model.slug)?.capabilities ?? null,
41-
slug: model.slug,
42-
name: model.display_name,
43-
isCustom: false,
44-
}) satisfies ServerProviderModel,
45-
);
39+
.map((model) => {
40+
const native = nativeModels.find((candidate) => candidate.slug === model.slug);
41+
const accessPrograms = codexAccessProgramOptionDescriptors(
42+
model.available_access_programs?.cyber.map((program) =>
43+
program === "daybreak_blue"
44+
? "daybreakBlue"
45+
: program === "daybreak_red"
46+
? "daybreakRed"
47+
: program,
48+
),
49+
);
50+
return {
51+
...native,
52+
capabilities:
53+
native?.capabilities || accessPrograms.length > 0
54+
? {
55+
...native?.capabilities,
56+
// The fresh account catalog owns entitlements, even if native metadata is cached.
57+
optionDescriptors: [
58+
...(native?.capabilities?.optionDescriptors ?? []).filter(
59+
(option) => option.id !== "cyberAccessProgram",
60+
),
61+
...accessPrograms,
62+
],
63+
}
64+
: null,
65+
slug: model.slug,
66+
name: model.display_name,
67+
isCustom: false,
68+
} satisfies ServerProviderModel;
69+
});
4670
}, Effect.timeout("15 seconds"));

0 commit comments

Comments
 (0)