feat(codex): require Codex 0.156 and regenerate its protocol (#13481)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Opus 5.5 authored and GitHub committed 2026-09-24 14:10:04 -07:00
1 parent 567783ecdc
commit d5d48742c9
14 files changed
+13611 -1823

No files matched your search

@@ -2383,6 +2383,7 @@ lifecycleLayer("CodexAdapterLive lifecycle", (it) => {
method: "item/tool/requestUserInput",
requestId: ApprovalRequestId.make("req-user-input-1"),
payload: {
isBlocking: true,
itemId: "item-user-input-1",
threadId: "thread-1",
turnId: "turn-1",
@@ -441,7 +441,7 @@ const probeCodexAppServerProvider = Effect.fn("probeCodexAppServerProvider")(fun
requestAllCodexModels(client),
// Usage is an enrichment: a failure or a slow answer degrades to "no
// usage this probe" rather than costing the account and models.
client.request("account/rateLimits/read", undefined).pipe(
client.request("account/rateLimits/read", null).pipe(
Effect.map((response): CodexRateLimitsProbe => ({
snapshot: response.rateLimits,
rateLimitsByLimitId: response.rateLimitsByLimitId,
@@ -90,25 +90,28 @@ describe("Codex thread history", () => {
);
}
it.effect("keeps the count-based rollback API for older threads", () =>
it.effect("surfaces Codex rejecting a revert of a legacy thread", () =>
Effect.gen(function* () {
const rejection = CodexErrors.CodexAppServerRequestError.invalidRequest(
"thread/revert only supports paginated threads",
);
const client: Parameters<typeof rollbackCodexThread>[0] = {
raw: { request: () => Effect.succeed({ thread: {} }) },
request: <M extends CodexRpc.ClientRequestMethod>(
method: M,
params: CodexRpc.ClientRequestParamsByMethod[M],
) => {
NodeAssert.equal(method, "thread/rollback");
NodeAssert.deepEqual(params, { threadId: "legacy-thread", numTurns: 2 });
raw: {
request: (method) => {
if (method === "thread/read") return Effect.succeed({ thread: {} });
if (method === "thread/revert") return Effect.fail(rejection);
return Effect.die(`Unexpected raw request: ${method}`);
},
},
request: <M extends CodexRpc.ClientRequestMethod>(method: M) => {
NodeAssert.equal(method, "thread/read");
return Effect.succeed({
thread: { id: "legacy-thread", turns: [] },
thread: { id: "legacy-thread", turns: [{ id: "turn-1", items: [] }] },
} as unknown as CodexRpc.ClientRequestResponsesByMethod[M]);
},
};
NodeAssert.deepEqual(yield* rollbackCodexThread(client, "legacy-thread", 2), {
threadId: "legacy-thread",
turns: [],
});
const error = yield* Effect.flip(rollbackCodexThread(client, "legacy-thread", 1));
NodeAssert.strictEqual(error, rejection);
}),
);
});
@@ -680,6 +683,7 @@ function makeThreadStartedNotification(
id: threadId,
modelProvider: "openai",
preview: "",
projectId: null,
sessionId: threadId,
source,
status: { type: "idle" as const },
@@ -163,8 +163,7 @@ export type CodexTurnStartParamsWithCollaborationMode =
export type CodexResumeCursor = typeof CodexResumeCursorSchema.Type;
type CodexServiceTier = NonNullable<EffectCodexSchema.V2ThreadStartParams["serviceTier"]>;
type CodexThreadItem =
| EffectCodexSchema.V2ThreadReadResponse["thread"]["turns"][number]["items"][number]
| EffectCodexSchema.V2ThreadRollbackResponse["thread"]["turns"][number]["items"][number];
EffectCodexSchema.V2ThreadReadResponse["thread"]["turns"][number]["items"][number];
export interface CodexSessionRuntimeOptions {
readonly threadId: ThreadId;
@@ -1185,7 +1184,7 @@ function updateSession(
}
function parseThreadSnapshot(
response: EffectCodexSchema.V2ThreadReadResponse | EffectCodexSchema.V2ThreadRollbackResponse,
response: EffectCodexSchema.V2ThreadReadResponse,
): CodexThreadSnapshot {
return {
threadId: response.thread.id,
@@ -1273,11 +1272,8 @@ export const rollbackCodexThread = Effect.fn("rollbackCodexThread")(function* (
threadId: string,
numTurns: number,
): Effect.fn.Return<CodexThreadSnapshot, CodexErrors.CodexAppServerError> {
if ((yield* readCodexHistoryMode(client, threadId)) !== "paginated") {
return parseThreadSnapshot(yield* client.request("thread/rollback", { threadId, numTurns }));
}
// Paginated threads replace history at a turn boundary instead of supporting
// the legacy count-based rollback endpoint.
// Codex replaces history at a turn boundary. It rejects threads that still
// use legacy history, which have no rollback API since Codex 0.156.
const snapshot = yield* readCodexThread(client, threadId);
const retainedCount = Math.max(0, snapshot.turns.length - numTurns);
const firstRemoved = snapshot.turns[retainedCount];
+5 -4
View File
@@ -1,14 +1,15 @@
{
"version": 1,
"updatedAt": "2026-09-24T00:11:29Z",
"updatedAt": "2026-09-24T18:40:00Z",
"compatibility": [
{
"driver": "codex",
"t3CodeRange": ">=0.0.42",
"recommendedRange": ">=0.129.0",
"recommendedRange": ">=0.156.0",
"ranges": [
{ "range": ">=0.129.0", "status": "supported" },
{ "range": "<0.129.0", "status": "broken" }
{ "range": ">=0.156.0", "status": "supported" },
{ "range": ">=0.149.0 <0.156.0", "status": "unsupported" },
{ "range": "<0.149.0", "status": "broken" }
]
},
{
@@ -65,6 +65,24 @@ describe("provider compatibility", () => {
}
});
it("supports Codex 0.156 and marks Codex without Thread.projectId broken", () => {
const bundled = ModelManifest.BUNDLED_MODEL_MANIFEST.compatibility;
for (const [t3CodeVersion, codexVersion, expected] of [
["0.0.42", "0.148.0", "broken"],
["0.0.42", "0.149.0", "unsupported"],
["0.0.42", "0.155.0", "unsupported"],
["0.0.42", "0.156.0", "supported"],
["0.0.43-nightly.20260924.2200", "0.153.3", "unsupported"],
["0.0.43-nightly.20260924.2200", "0.156.1", "supported"],
] as const) {
assert.strictEqual(
resolveProviderCompatibility(bundled, driver, codexVersion, t3CodeVersion)?.status,
expected,
`T3 Code ${t3CodeVersion} with Codex ${codexVersion}`,
);
}
});
it("compares Cursor build dates without treating semver prereleases as stable", () => {
const cursor = ProviderDriverKind.make("cursor");
const cursorPolicy: ProviderCompatibilityPolicy = {
@@ -20,6 +20,7 @@
"forkedFromId": null,
"parentThreadId": null,
"preview": "",
"projectId": null,
"ephemeral": false,
"historyMode": "legacy",
"modelProvider": "openai",
@@ -389,6 +390,7 @@
"forkedFromId": null,
"parentThreadId": null,
"preview": "",
"projectId": null,
"ephemeral": false,
"historyMode": "legacy",
"modelProvider": "openai",