From 3ecd5ff17cc60526c4fedfd8fe5c561c9ab988e9 Mon Sep 17 00:00:00 2001 From: "Nikolai.Sviridov" Date: Mon, 5 Jan 2026 23:53:51 +0100 Subject: [PATCH 1/2] feat: change model encoding --- src/CodexAcpClient.ts | 2 + src/CodexAppServerClient.ts | 8 +-- src/ModelId.ts | 19 +++---- .../CodexACPAgent/CodexAcpClient.test.ts | 2 +- .../CodexACPAgent/data/auth-with-key.json | 49 ++----------------- .../data/start-conversation.json | 49 ++----------------- 6 files changed, 24 insertions(+), 105 deletions(-) diff --git a/src/CodexAcpClient.ts b/src/CodexAcpClient.ts index 2997a0ec..95c4ee4d 100644 --- a/src/CodexAcpClient.ts +++ b/src/CodexAcpClient.ts @@ -117,11 +117,13 @@ export class CodexAcpClient { developerInstructions: null, experimentalRawEvents: false }); + const codexModels = await this.fetchAvailableModels(); if (codexModels.length === 0) { throw new Error("Codex did not return any models"); } const currentModelId = ModelId.fromThreadResponse(threadStartResponse).toString(); + return { sessionId: threadStartResponse.thread.id, currentModelId: currentModelId, diff --git a/src/CodexAppServerClient.ts b/src/CodexAppServerClient.ts index c2bddf24..6089c12a 100644 --- a/src/CodexAppServerClient.ts +++ b/src/CodexAppServerClient.ts @@ -7,6 +7,8 @@ import type { } from "./app-server"; import type { AccountLoginCompletedNotification, AccountUpdatedNotification, + ConfigReadParams, + ConfigReadResponse, GetAccountParams, GetAccountResponse, LoginAccountParams, LoginAccountResponse, LogoutAccountResponse, ModelListParams, ModelListResponse, @@ -174,11 +176,11 @@ export class CodexAppServerClient { callback({ eventType: "request", ...request}); } let result: any; - if (request.params) { + if (request.params !== undefined) { result = await this.connection.sendRequest(request.method, request.params) } else { - await this.connection.sendRequest(request.method); + result = await this.connection.sendRequest(request.method); } for (const callback of this.codexEventHandlers) { callback({ eventType: "response", ...result}); @@ -193,4 +195,4 @@ type CodexRequest = DistributiveOmit type DistributiveOmit = T extends any ? Omit - : never; \ No newline at end of file + : never; diff --git a/src/ModelId.ts b/src/ModelId.ts index ab1abfc5..53ff061b 100644 --- a/src/ModelId.ts +++ b/src/ModelId.ts @@ -1,4 +1,4 @@ -import type {ReasoningEffort} from "./app-server"; +import type {ReasoningEffort, SetDefaultModelParams} from "./app-server"; import type {Model, ThreadStartResponse} from "./app-server/v2"; export class ModelId { @@ -16,17 +16,18 @@ export class ModelId { } static fromString(modelId: string): ModelId { - const parts = modelId.split("/"); - const model = parts[0]; - const effort = parts[1] ?? null; + const bracketMatch = modelId.match(/^(?[^\[]+?)(?:\[(?[^\]]+)\])?$/); + const model = bracketMatch?.groups?.["model"]; + const effort = bracketMatch?.groups?.["effort"] ?? null; - if (!model) { - throw new Error(`Invalid modelId format: ${modelId}`); + if (model) { + return new ModelId(model, effort); } - return new ModelId(model, effort); + + throw new Error(`Invalid modelId format: ${modelId}`); } toString(): string { - return this.effort ? `${this.model}/${this.effort}` : this.model; + return this.effort ? `${this.model}[${this.effort}]` : this.model; } -} \ No newline at end of file +} diff --git a/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts b/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts index b783cee6..edff6ab6 100644 --- a/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts +++ b/src/__tests__/CodexACPAgent/CodexAcpClient.test.ts @@ -16,7 +16,7 @@ describe('ACP server test', { timeout: 40_000 }, () => { vi.clearAllMocks(); }); - const ignoredFields = ["thread", "cwd", "id", "createdAt", "path", "threadId", "userAgent", "sandbox", "reasoningEffort", "conversationId"]; + const ignoredFields = ["thread", "cwd", "id", "createdAt", "path", "threadId", "userAgent", "sandbox", "conversationId", "origins", "projects", "supportedReasoningEfforts", "reasoningEffort"]; it('should start conversation', async () => { const codexAcpAgent = fixture.getCodexAcpAgent(); diff --git a/src/__tests__/CodexACPAgent/data/auth-with-key.json b/src/__tests__/CodexACPAgent/data/auth-with-key.json index 327de680..1deef96a 100644 --- a/src/__tests__/CodexACPAgent/data/auth-with-key.json +++ b/src/__tests__/CodexACPAgent/data/auth-with-key.json @@ -88,24 +88,7 @@ "model": "gpt-5.1-codex-max", "displayName": "gpt-5.1-codex-max", "description": "Codex-optimized flagship for deep and fast reasoning.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Fast responses with lighter reasoning" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed and reasoning depth for everyday tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Greater reasoning depth for complex problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning depth for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": true }, @@ -114,16 +97,7 @@ "model": "gpt-5.1-codex-mini", "displayName": "gpt-5.1-codex-mini", "description": "Optimized for codex. Cheaper, faster, but less capable.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Dynamically adjusts reasoning based on the task" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false }, @@ -132,24 +106,7 @@ "model": "gpt-5.2", "displayName": "gpt-5.2", "description": "Latest frontier model with improvements across knowledge, reasoning and coding", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed with some reasoning; useful for straightforward queries and short explanations" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Provides a solid balance of reasoning depth and latency for general-purpose tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false } diff --git a/src/__tests__/CodexACPAgent/data/start-conversation.json b/src/__tests__/CodexACPAgent/data/start-conversation.json index e509a315..f45f7380 100644 --- a/src/__tests__/CodexACPAgent/data/start-conversation.json +++ b/src/__tests__/CodexACPAgent/data/start-conversation.json @@ -77,24 +77,7 @@ "model": "gpt-5.1-codex-max", "displayName": "gpt-5.1-codex-max", "description": "Codex-optimized flagship for deep and fast reasoning.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Fast responses with lighter reasoning" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed and reasoning depth for everyday tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Greater reasoning depth for complex problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning depth for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": true }, @@ -103,16 +86,7 @@ "model": "gpt-5.1-codex-mini", "displayName": "gpt-5.1-codex-mini", "description": "Optimized for codex. Cheaper, faster, but less capable.", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Dynamically adjusts reasoning based on the task" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false }, @@ -121,24 +95,7 @@ "model": "gpt-5.2", "displayName": "gpt-5.2", "description": "Latest frontier model with improvements across knowledge, reasoning and coding", - "supportedReasoningEfforts": [ - { - "reasoningEffort": "reasoningEffort", - "description": "Balances speed with some reasoning; useful for straightforward queries and short explanations" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Provides a solid balance of reasoning depth and latency for general-purpose tasks" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Maximizes reasoning depth for complex or ambiguous problems" - }, - { - "reasoningEffort": "reasoningEffort", - "description": "Extra high reasoning for complex problems" - } - ], + "supportedReasoningEfforts": "supportedReasoningEfforts", "defaultReasoningEffort": "medium", "isDefault": false } From 0d015e2027676083f7d5dae61fbd4d67c19ba5e2 Mon Sep 17 00:00:00 2001 From: "Nikolai.Sviridov" Date: Wed, 7 Jan 2026 17:17:23 +0100 Subject: [PATCH 2/2] feat: remove unused code, revert app server changes --- src/CodexAppServerClient.ts | 8 +++----- src/ModelId.ts | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/CodexAppServerClient.ts b/src/CodexAppServerClient.ts index 6089c12a..c2bddf24 100644 --- a/src/CodexAppServerClient.ts +++ b/src/CodexAppServerClient.ts @@ -7,8 +7,6 @@ import type { } from "./app-server"; import type { AccountLoginCompletedNotification, AccountUpdatedNotification, - ConfigReadParams, - ConfigReadResponse, GetAccountParams, GetAccountResponse, LoginAccountParams, LoginAccountResponse, LogoutAccountResponse, ModelListParams, ModelListResponse, @@ -176,11 +174,11 @@ export class CodexAppServerClient { callback({ eventType: "request", ...request}); } let result: any; - if (request.params !== undefined) { + if (request.params) { result = await this.connection.sendRequest(request.method, request.params) } else { - result = await this.connection.sendRequest(request.method); + await this.connection.sendRequest(request.method); } for (const callback of this.codexEventHandlers) { callback({ eventType: "response", ...result}); @@ -195,4 +193,4 @@ type CodexRequest = DistributiveOmit type DistributiveOmit = T extends any ? Omit - : never; + : never; \ No newline at end of file diff --git a/src/ModelId.ts b/src/ModelId.ts index 53ff061b..4618f2c3 100644 --- a/src/ModelId.ts +++ b/src/ModelId.ts @@ -1,4 +1,4 @@ -import type {ReasoningEffort, SetDefaultModelParams} from "./app-server"; +import type {ReasoningEffort} from "./app-server"; import type {Model, ThreadStartResponse} from "./app-server/v2"; export class ModelId {