Skip to content

fix(acp): synchronize plan mode and handle missing plan files - #5404

Merged
RealKai42 merged 1 commit into
mainfrom
codex/issue-022-acp-plan-mode
Nov 25, 2026
Merged

RealKai42 merged 1 commit into
mainfrom
codex/issue-022-acp-plan-mode

Conversation

@RealKai42

Copy link
Copy Markdown
Collaborator

Screenshots / Recordings

下面是同一组 session/new 请求的实际响应摘录。配置开启了 default_plan_mode,编辑器声明了文本文件读取能力。

模式选择器的响应

修复前

{
  "currentModeId": "default",
  "configMode": "default",
  "editorFileReads": 0
}

修复后

{
  "currentModeId": "plan",
  "configMode": "plan",
  "editorFileReads": 0
}

Requirement or Bug

编辑器声明文件能力时,首次进入 Plan 模式会遇到尚不存在的计划文件,回合因此失败。新建或恢复会话时的模式选择器也可能显示错误状态,批准计划或选择「拒绝并退出」后容易停留在 Plan。

Bug Reproduction Steps

  1. 客户端声明 fs.readTextFile 和 fs.writeTextFile,进入 Plan 模式并发送提示。让客户端针对不存在的计划文件返回 ACP -32002。基线回合无法继续到计划审阅。
  2. 配置 default_plan_mode = true 并创建会话。modes.currentModeId 和 configOptions 都返回 default。

Root Cause

ACP 文件适配没有把读文件时的 -32002 归为引擎能够处理的缺文件。模式选择器由 ACP 缓存,而批准或拒绝计划会直接修改引擎的 Plan 状态。

Code Changes

flowchart LR
    E[编辑器] -->|计划文件尚不存在| F[ACP 文件适配]
    F -->|文件不存在| P[引擎创建和审阅计划]
    P -->|模式状态变更| M[ACP 读取实际 Plan 和权限状态]
    M -->|模式与配置通知| E
Loading

ACP 将编辑器的缺文件错误转换为已有的 host 文件错误。初始模式与后续通知都读取 live main agent 的 Plan 标志和实际权限,建立会话时即可拿到状态。显式切换完成后发布最终模式,批准和拒绝退出则由引擎事件触发通知。

Behavior Changes and Affected Users

行为 改动前 改动后 受影响人群
计划文件首次读取 编辑器的 -32002 中断回合 引擎可以继续创建计划并提交审阅 声明文本文件读写能力的 ACP 编辑器用户
新建或恢复 Plan 模式 模式选择器可能显示 default 两种选择器返回实际生效的模式 配置了默认 Plan 或恢复计划会话的用户
批准计划或拒绝并退出 编辑器可能继续显示 Plan 模式和配置通知反映实际权限,例如 YOLO 使用 ACP 计划审批的编辑器与用户

Verification

  • macOS 本地用 ACP 服务端和测试编辑器通过实际 NDJSON 交互复现。打补丁前,5 个新增断言对应的用例失败。定向回归连续执行 7 轮,共 49 次通过。
  • ACP 文件适配、配置、完整回合、交互桥接与引擎 Plan 套件共 11 个测试文件、180 项通过。覆盖缺文件、读写计划、批准、拒绝并退出、默认权限与 YOLO、新建及恢复会话、显式切换。
  • pnpm lint、ACP 类型检查、CLI 构建与 smoke、双语文档构建、98 项仓库检查测试均通过。平台验证使用 macOS。

Checklist

  • 阅读贡献指南,在基线用真实 ACP 协议复现。
  • 覆盖缺文件、计划审批、模式恢复和显式切换。
  • 更新双语 ACP 参考与两条 patch changeset。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-25T08:40:30.744176Z 8760ab1 PR opened
🔒 Security Review ✅ Completed 2026-11-25T08:42:39.062668Z 8760ab1 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@RealKai42
RealKai42 merged commit 9abb45c into main Nov 25, 2026
15 of 36 checks passed
@RealKai42
RealKai42 deleted the codex/issue-022-acp-plan-mode branch November 25, 2026 10:03
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
MoonshotAI#5359 and MoonshotAI#5404 need the fork's loop/ACP shapes (LiveTurn state machine,
session extensions), MoonshotAI#5434 depends on testkit signal imports, and MoonshotAI#5332
needs a merged SessionAction table. Each is in_progress with the precise
remaining work rather than a forced apply.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 25, 2026
…AI#5404)

Port the ACP half: permission modes are lowercased onto AcpModeId, the
server resolves a live session's plan/permission state into modes, session
initialization and set_mode publish current_mode_update, and readTextFile
maps ACP -32002 (missing file) to OS_FS_NOT_FOUND so plan-file reads can
fall back.

Verified: acp-server config + acp-fs 33 pass, typecheck clean. The e2e
plan-mode test stays on the row; the fork's e2e-turn still uses
scriptedProvider.
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 26, 2026
Record the attempted testkit fake-model migration for MoonshotAI#5404/MoonshotAI#5385: the plan-review cases pass, but ToolUpdated field propagation, /usage context size, /compact scripting and the two terminal reverse-RPC cases need a dedicated test-engine update, so the suite stays on scriptedProvider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant