Skip to content

Commit 9840669

Browse files
committed
fix(reasoning): honor configured summary mode
Respect model_reasoning_summary from CODEX_CONFIG env for prompt turns while preserving compatibility guards and the default thinking stream.
1 parent f3f1b3c commit 9840669

2 files changed

Lines changed: 39 additions & 9 deletions

File tree

src/CodexAcpClient.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import type {Disposable} from "vscode-jsonrpc";
1313
import type {
1414
ClientInfo,
1515
ReasoningEffort,
16+
ReasoningSummary,
1617
ServiceTier,
1718
ServerNotification
1819
} from "./app-server";
@@ -672,7 +673,8 @@ export class CodexAcpClient {
672673
input: input,
673674
approvalPolicy: agentMode.approvalPolicy,
674675
sandboxPolicy: addAdditionalDirectoriesToSandboxPolicy(agentMode.sandboxPolicy, additionalDirectories),
675-
summary: disableSummary ? "none" : "auto",
676+
// Preserve safety overrides while honoring CODEX_CONFIG.
677+
summary: resolveReasoningSummary(this.config, disableSummary),
676678
effort: effort,
677679
model: modelId.model,
678680
serviceTier: serviceTier,
@@ -841,6 +843,22 @@ export class CodexAcpClient {
841843

842844
export type JsonObject = { [key in string]?: JsonValue }
843845

846+
function resolveReasoningSummary(config: JsonObject, disableSummary: boolean): ReasoningSummary {
847+
if (disableSummary) {
848+
return "none";
849+
}
850+
851+
switch (config["model_reasoning_summary"]) {
852+
case "auto":
853+
case "concise":
854+
case "detailed":
855+
case "none":
856+
return config["model_reasoning_summary"];
857+
default:
858+
return "auto";
859+
}
860+
}
861+
844862
export type SessionMetadata = {
845863
sessionId: string,
846864
currentModelId: string,

src/__tests__/CodexACPAgent/CodexAcpClient.test.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {AgentMode} from "../../AgentMode";
1616
import type {Model, ReviewStartResponse, ThreadGoal, TurnCompletedNotification, TurnStartParams} from "../../app-server/v2";
1717
import type {RateLimitsMap} from "../../RateLimitsMap";
1818
import {ModelId} from "../../ModelId";
19+
import {CodexAcpClient} from "../../CodexAcpClient";
1920

2021
describe('ACP server test', { timeout: 40_000 }, () => {
2122

@@ -3057,14 +3058,25 @@ describe('ACP server test', { timeout: 40_000 }, () => {
30573058
expect(turnStartSpy).toHaveBeenCalledWith(expect.objectContaining({ summary: "none" }));
30583059
});
30593060

3060-
it ('should enable reasoning.summary by default', async () => {
3061-
const { mockFixture, turnStartSpy } = setupPromptFixture({
3062-
account: { type: "chatgpt", email: "test@example.com", planType: "pro" },
3063-
});
3061+
// Explicit adapter config must override the default summary mode.
3062+
it ('should prefer CODEX_CONFIG reasoning.summary', async () => {
3063+
const { mockFixture, turnStartSpy } = setupPromptFixture();
3064+
const configuredClient = new CodexAcpClient(
3065+
mockFixture.getCodexAppServerClient(),
3066+
{model_reasoning_summary: "detailed"},
3067+
);
30643068

3065-
await mockFixture.getCodexAcpAgent().prompt({ sessionId: "id", prompt: [{ type: "text", text: "test" }] });
3069+
await configuredClient.sendPrompt(
3070+
{sessionId: "id", prompt: [{type: "text", text: "test"}]},
3071+
AgentMode.DEFAULT_AGENT_MODE,
3072+
ModelId.create("model-id", "medium"),
3073+
null,
3074+
false,
3075+
"/test/cwd",
3076+
[],
3077+
);
30663078

3067-
expect(turnStartSpy).toHaveBeenCalledWith(expect.objectContaining({ summary: "auto" }));
3079+
expect(turnStartSpy).toHaveBeenCalledWith(expect.objectContaining({summary: "detailed"}));
30683080
});
30693081

30703082
it ('should disable reasoning.summary when model lacks reasoning', async () => {
@@ -3078,7 +3090,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
30783090
expect(turnStartSpy).toHaveBeenCalledWith(expect.objectContaining({ summary: "none" }));
30793091
});
30803092

3081-
it ('should enable reasoning.summary when model supports reasoning', async () => {
3093+
it ('should use auto reasoning.summary by default when model supports reasoning', async () => {
30823094
const { mockFixture, turnStartSpy } = setupPromptFixture({
30833095
account: { type: "chatgpt", email: "test@example.com", planType: "pro" },
30843096
supportedReasoningEfforts: [
@@ -3089,7 +3101,7 @@ describe('ACP server test', { timeout: 40_000 }, () => {
30893101

30903102
await mockFixture.getCodexAcpAgent().prompt({ sessionId: "id", prompt: [{ type: "text", text: "test" }] });
30913103

3092-
expect(turnStartSpy).toHaveBeenCalledWith(expect.objectContaining({ summary: "auto" }));
3104+
expect(turnStartSpy).toHaveBeenCalledWith(expect.objectContaining({summary: "auto"}));
30933105
});
30943106

30953107
it ('should reject prompt with images when model does not support image input', async () => {

0 commit comments

Comments
 (0)