From 3e00128a0375a7477981f0a322447f74d9406d94 Mon Sep 17 00:00:00 2001 From: Zixuan Chen Date: Fri, 17 Jul 2026 17:05:38 +0800 Subject: [PATCH] feat: add agent auto-review mode Adds a fourth session mode `agent-auto-review`: same workspace-write sandbox and on-request approval policy as `agent`, but routes approval requests to Codex's auto-review subagent (`approvalsReviewer: auto_review`) instead of the ACP client, matching the Codex app's "Approve for me" permission preset. Model: kimi-code/k3 --- README.md | 2 +- readme-dev.md | 2 +- src/AgentMode.ts | 23 ++++++++++++++++--- src/CodexAcpClient.ts | 1 + .../data/send-attachments-turn-start.json | 1 + 5 files changed, 24 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5e837f89..1e7418b2 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ mode, and configuration; slash commands cannot be steered. - `CODEX_CONFIG` - JSON object merged into the Codex session config. - `MODEL_PROVIDER` - model provider to pass to Codex for new sessions. - `DEFAULT_AUTH_REQUEST` - ACP auth request JSON used when Codex requires authentication. -- `INITIAL_AGENT_MODE` - initial mode id: `read-only`, `agent`, or `agent-full-access`. +- `INITIAL_AGENT_MODE` - initial mode id: `read-only`, `agent`, `agent-auto-review`, or `agent-full-access`. - `NO_BROWSER` - hide browser-based ChatGPT auth when set. - `APP_SERVER_LOGS` - directory for adapter logs. diff --git a/readme-dev.md b/readme-dev.md index 41009c7b..c8bbab24 100644 --- a/readme-dev.md +++ b/readme-dev.md @@ -9,7 +9,7 @@ Set `CODEX_PATH` to run a different Codex binary; versions other than the one sp - `CODEX_CONFIG` - JSON object merged into the Codex session config. - `MODEL_PROVIDER` - model provider to pass to Codex for new sessions. - `DEFAULT_AUTH_REQUEST` - ACP auth request JSON used when Codex requires authentication. -- `INITIAL_AGENT_MODE` - initial mode id: `read-only`, `agent`, or `agent-full-access`. +- `INITIAL_AGENT_MODE` - initial mode id: `read-only`, `agent`, `agent-auto-review`, or `agent-full-access`. - `NO_BROWSER` - hide browser-based ChatGPT auth when set. - `APP_SERVER_LOGS` - directory for adapter logs. diff --git a/src/AgentMode.ts b/src/AgentMode.ts index aed9710c..9fb2229f 100644 --- a/src/AgentMode.ts +++ b/src/AgentMode.ts @@ -1,4 +1,4 @@ -import type {AskForApproval, SandboxMode, SandboxPolicy} from "./app-server/v2"; +import type {ApprovalsReviewer, AskForApproval, SandboxMode, SandboxPolicy} from "./app-server/v2"; import type {SessionConfigOption, SessionMode, SessionModeState} from "@agentclientprotocol/sdk"; export const MODE_CONFIG_ID = "mode"; @@ -10,14 +10,16 @@ export class AgentMode { readonly approvalPolicy: AskForApproval; readonly sandboxPolicy: SandboxPolicy; readonly sandboxMode: SandboxMode; + readonly approvalsReviewer: ApprovalsReviewer; - private constructor(id: string, name: string, description: string, approval: AskForApproval, sandbox: SandboxPolicy, sandboxMode: SandboxMode) { + private constructor(id: string, name: string, description: string, approval: AskForApproval, sandbox: SandboxPolicy, sandboxMode: SandboxMode, approvalsReviewer: ApprovalsReviewer = "user") { this.id = id; this.name = name; this.description = description; this.approvalPolicy = approval; this.sandboxPolicy = sandbox; this.sandboxMode = sandboxMode; // same as sandboxPolicy, need to look for + this.approvalsReviewer = approvalsReviewer; } static readonly ReadOnly = new AgentMode( @@ -45,6 +47,21 @@ export class AgentMode { }, "workspace-write" ); + static readonly AgentAutoReview = new AgentMode( + "agent-auto-review", + "Agent (auto review)", + "Read and edit files, and run commands. Approval requests are reviewed automatically by a Codex subagent.", + "on-request", + { + type: "workspaceWrite", + writableRoots: [], + networkAccess: false, + excludeTmpdirEnvVar: false, + excludeSlashTmp: false + }, + "workspace-write", + "auto_review" + ); static readonly AgentFullAccess = new AgentMode( "agent-full-access", "Agent (full access)", @@ -88,7 +105,7 @@ export class AgentMode { } static all(): AgentMode[] { - return [AgentMode.ReadOnly, AgentMode.Agent, AgentMode.AgentFullAccess]; + return [AgentMode.ReadOnly, AgentMode.Agent, AgentMode.AgentAutoReview, AgentMode.AgentFullAccess]; } static find(modeId: string): AgentMode | null { diff --git a/src/CodexAcpClient.ts b/src/CodexAcpClient.ts index 36516caf..7ae09a92 100644 --- a/src/CodexAcpClient.ts +++ b/src/CodexAcpClient.ts @@ -682,6 +682,7 @@ export class CodexAcpClient { threadId: request.sessionId, input: input, approvalPolicy: agentMode.approvalPolicy, + approvalsReviewer: agentMode.approvalsReviewer, sandboxPolicy: addAdditionalDirectoriesToSandboxPolicy(agentMode.sandboxPolicy, additionalDirectories), summary: disableSummary ? "none" : "auto", effort: effort, diff --git a/src/__tests__/CodexACPAgent/data/send-attachments-turn-start.json b/src/__tests__/CodexACPAgent/data/send-attachments-turn-start.json index cad1559e..39b1bc66 100644 --- a/src/__tests__/CodexACPAgent/data/send-attachments-turn-start.json +++ b/src/__tests__/CodexACPAgent/data/send-attachments-turn-start.json @@ -47,6 +47,7 @@ } ], "approvalPolicy": "on-request", + "approvalsReviewer": "approvalsReviewer", "sandboxPolicy": { "type": "workspaceWrite", "writableRoots": [],