Skip to content

feat(agent-core-v2): add experimental auto review and read-only Bash approvals - #4655

Open
7Sageer wants to merge 66 commits into
mainfrom
auto-review
Open

7Sageer wants to merge 66 commits into
mainfrom
auto-review

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Requirement or Bug

为 Ask When Needed(yolo)和 Never Ask(auto)权限模式提供独立的 LLM 工具调用复核,作为默认关闭的实验能力。这两个模式省掉的是 Always Ask 模式下的人工确认;Auto Review 让一个独立模型代替人,对这些原本会问人的调用做一次判断。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:reviewer 替代 Always Ask 下的人工确认。实验开启时,策略链一次遍历同时给出实际结果和去掉模式级放行后的结果:实际结果是 ask 就送审;实际结果是模式级放行、底层结果仍是 ask 也送审。显式 deny、默认放行工具、Git 工作区内写入、用户 allow 规则和本会话已批准沿用原结果。AutoReviewFeature 在 Agent scope 贡献 AutoReviewService 并向 IAgentPermissionGate.registerReviewer 注册复核门控,src/agent/permissionGate 与 src/agent/permissionPolicy 不依赖 src/features/autoReview。reviewer 在 AutoReviewService 内按所选模型组装参数,通过 IProtocolAdapterRegistry 创建独立请求器,调用其 .with(...).generate() 完成复核并按 operation 记入会话用量,不侵入主循环 AgentLoopRequester。

flowchart TD
    A["工具调用"] --> B["静态策略链"]
    B --> C{"静态 ask?"}
    C -- "是" --> H["其他 listener 表态后,LLM 复核"]
    C -- "否" --> D{"命中模式级放行?"}
    D -- "否" --> G["沿用静态结果"]
    D -- "是" --> F{"同一次遍历的底层结果是 ask?"}
    F -- "否" --> G
    F -- "是" --> H
    H --> I{"allow?"}
    I -- "是" --> G
    I -- "deny 或失败" --> J{"复核结束时的模式"}
    J -- "yolo" --> K["转人工审批"]
    J -- "auto" --> L["不执行,返回工具错误"]
Loading

底层结果来自同一次遍历里模式级放行之后的下一条策略,所以"哪些调用需要审"只有一个真相来源,不需要再维护工具豁免名单,也不再重跑策略链。权限门留在 permitting 阶段,通过 runLegacyStarting 共享 legacy 事件的 listener 顺序与 waitUntil 结算;复核由 listener 注册 deferReview,等其他 listener 的 veto 或 final allow 生效后才启动。普通 skipPermitting 仍会绕过权限门,legacy final allow 经 legacyStartingDecision 转为 skipPermitting,veto 在 starting 阶段短路;策略评估异常继续返回 permitting hook failed for "...": ... 的工具错误。工具不会在权限决议前启动。复核上下文通过 IAgentLoopService.history() 读取自己和主 Agent 的历史,适配最新 main 的 loop runtime,不恢复已删除的 context-memory 服务。

Reviewer Prompt 已收敛为 Environment、风险规则、Authorization 和 Decision 四段,保持 {risk, decision, reason} 输出契约。Environment 根据 cwd、gitStatus 与实际效果判断本地和外部目标;medium 风险要求明确覆盖操作、危险目标和范围的用户或项目授权,high 风险始终拒绝。原有代码质量边界、历史调用只作为事实、压缩摘要不提供授权等约束保留为概括表述。

本次只修改 Prompt,不引入第二阶段模型请求;Assistant 正文尚未加入输入,Prompt 中的“具体提案后用户确认”仅适用于现有授权内容能够直接表达的场景。

Reviewer 将逐文件恢复助手本会话自己创建或编辑的文件视为 low-risk local work,避免把按用户要求撤回越界实现误判为破坏性覆盖。这条规则只在 pending action 不涉及用户或其他 Agent 改动时适用。

新增 analyzeBashReadOnly:使用仓库现有的 IBashParserService 解析完整命令,逐段检查只读命令、字面量参数、重定向与待读取路径。只有每个命令段都能静态证明只读,才命中 bash-read-only-approve;该策略位于 fallback-ask 之前,用户 ask/deny、敏感文件、.git 与原危险命令策略保持在前。Auto Review 的策略遍历把 underlying = approve 的调用视为默认放行,因此只读命令在 Always Ask / manual 下直接执行,开启实验也不送审。

同一轮里多条要复核的命令,复核请求并行发出,最多同时 4 个。每条调用的其他中央 legacy listener 先完成 veto / final allow,再启动复核;复核决策与人工审批在各调用的 waitUntil 阶段等待。每次 legacy starting 决议结束时取消该调用尚未完成的复核,沿用 main 的并发 handler 语义,不恢复旧的 stopBatch 路径。

审批弹窗里 shell 命令上方的 Dangerous: 启发式标注同步收窄:rm 只有带递归标志(-r/-R/--recursive)才标 recursive delete,纯强制删除(rm -f/--force)改标 force delete,并去掉单独的 sudo 标注。此前 rm -f file 和 sudo rm -f 都会被误标为 recursive delete。

关键决策

决策 选择 没选 理由
送审范围 Always Ask 会问人的调用(同一次遍历的底层结果) 工具豁免名单 + 来源标记,或跳过模式级放行再跑一遍 reviewer 代替的是人工确认,不应比 Always Ask 更严;名单会和默认放行列表漂移。第二次遍历会重复 deny、用户规则这些已经返回空的策略
权限门与特性边界 AutoReviewFeature 经 IAgentPermissionGate.registerReviewer 挂载复核门控与策略评估选项 AgentPermissionGate 和 AgentPermissionPolicyService 直接依赖 features/autoReview 保持依赖方向从 src/features/autoReview 指向 src/agent/ 核心层,关闭实验或单测核心权限服务时无耦合
复核请求通道 AutoReviewService 内使用 IProtocolAdapterRegistry 的独立核心请求器,沿用 resolveCompletionBudget 与 isRetryableGenerateError IAgentLoopService.requester 或单独 IModelRequester 服务 复核是异构模型、无工具、单条消息的短请求,内联调用不污染主循环请求器的状态与事件流,也不增加只有单调用方的服务层
thinking 复核请求关闭 thinking;模型不能关闭时落到它自己的默认档 跟随主循环档位,或 reviewer 单独再配一档 复核是一次无工具的 JSON 判断。主循环的高档位会占满默认 30 秒截止,把一次还没判完的复核收成人工审批
审批弹窗展示 reviewer 理由 在 TUI、desktop/web 待审批操作上方显示风险与理由 覆写审批请求的 action 保留原命令、diff、文件卡片,用户能理解拒绝原因后自行决定是否批准
审批弹窗 shell 危险标注 任何 rm -f/--force 及 sudo 前缀都标 recursive delete/sudo 仅 rm 带递归标志时标 recursive delete;纯强制删除标 force delete;不再单独标 sudo 看到审批弹窗危险提示的全部用户(yolo/auto 复核转人工后更常见)
同一轮多条复核 请求并行,最多 4 个;在各调用的 waitUntil 阶段等待决策与审批 逐条等上一次复核和审批结束再发下一次 串行会把整批启动时间加成每次复核的延迟,而后一条复核看不到前一条的输出
只读 Bash 静态放行 所有未配置放行的 Bash 都落到人工审批或 Auto Review 用现有 parser 分析完整命令,只对可静态证明只读的调用直接放行 让只读操作遵循与默认放行工具相同的审批路径,避免每个 cat、ls 都多一次确认或模型复核;解析失败时不放行

阅读指南

  • packages/agent-core-v2/src/features/autoReview/autoReviewFeature.ts:向 Agent scope 装配 IAutoReviewService。

  • packages/agent-core-v2/src/features/autoReview/autoReviewGate.ts:createAutoReviewReviewer 提供策略评估选项、autoReviewTrigger 触发判断、resolveAutoReview 的 yolo / auto 分流与人工批准回调记录。

  • packages/agent-core-v2/src/agent/permissionPolicy/permissionPolicyService.ts:按调用方传入的 PermissionPolicyEvaluateOptions 在单次遍历中带出 underlying 或跳过危险命令识别;默认命中即返回。

  • packages/agent-core-v2/src/agent/permissionPolicy/policies/bash-read-only.ts:只读命令表、完整命令段的收集与重定向分析,导出纯函数 analyzeBashReadOnly;敏感文件和 .git 检查仍由中央策略链负责。

  • packages/agent-core-v2/src/features/autoReview/reviewService.ts:模型选择、参数与输出预算解析、子 Agent 继承主 Agent 人类授权指令、人工批准调用记录、目标目录 Git 工作树状态探测、截止时间、复核期间指令变化的处理、用量与埋点。

  • packages/agent-core-v2/src/features/autoReview/context.ts:授权指令原样送出,不按条数或字符裁剪;导入会话不作为当前用户授权。历史只保留已完成或排在当前待审调用之前的 tool-call(人工批准过的调用带 approved: true),不附带 tool-result 与 toolMetadata;<pending_action> 携带待审调用参数与目标目录的 gitStatus,同批未执行的后续调用不会作为事实送审。

  • packages/app-core/src/client/conversationToTurns.ts 与 packages/app-components/src/chat/tool-calls/:保留复核阶段的参数预览,并在工具行与活动摘要显示状态。

  • packages/app-core/src/api/daemon/wire.ts、packages/app-core/src/client/toolCalls.ts 与 apps/desktop/src/renderer/components/chat/ApprovalCard.vue:审批元数据从 KAP wire 到现有审批卡片的传递。

permissionGateService.ts 的 registerReviewer 接线、配置文档和测试可以略读。

全屏 TUI 的提示走同一条 auto_review.started / auto_review.decision 事件链。折叠时组标题仍是正在做的事,复核状态放在尾部,写成 Reviewing <subject>,2 秒后带耗时;这条调用不进 Running 尾部。展开时标题不动,工具卡片里留一行 dim 的 Reviewing…,尾部不再重复。内联模式没有组尾部,卡片里同样一行。决策或取消后清除。审批弹窗的拒绝理由留在命令上方,标题用 warning,正文 dim,最多两行。

原 code-app #1240 的 GUI 改动已合并到本 PR:App 源码现由本仓 apps/desktop 与 packages/app-* 维护,desktop 与 Web 共用 apps/desktop/src/renderer。auto_review 工具阶段经 conversationToTurns 投影到活动摘要和 Bash / Edit / Generic 工具卡片,显示 Auto Review in progress… / 正在自动复核…;approval_detail 经 wire 与 ApprovalBlock.review 进入 ApprovalCard.vue,在原操作上方展示风险标题和理由。两端沿用现有卡片,不新增会话项。

Screenshots / Recordings

全屏折叠,复核等待中。标题保持工作摘要,状态在尾部:

  Running commands
  └ Reviewing echo hi

全屏展开,同一句话只出现在卡片里:

 ● Running commands

   Bash echo hi
     Reviewing…

复核拒绝后的审批弹窗。理由在命令上方,不使用 Dangerous: 的 error 加粗:

▶ Run this command?

  Auto Review: denied (medium risk)
  Creating remote resources was not explicitly authorized.
  $ ssh example.test -- reboot

此前真实交互验证中,reviewer 放行后提示消失并恢复工具结果:

● $ pwd
  /tmp/example-workspace

● done
复核请求的细节
  • 模型:[auto_review] model 优先;未配置时使用 [secondary_model] 默认模型,再回退到主模型。
  • 并发:同一轮多条复核请求并行发出,最多同时 4 个。排队等待计入同一条 30 秒截止;本条取消或截止到达时,不再发这一次。复核决策与人工审批在各调用的 waitUntil 阶段等待,每次 legacy starting 决议结束时取消该调用尚未完成的复核。
  • 请求:无工具、严格 JSON schema。provider 收到根 object JSON schema,本地验收约束交叉组合:allow 只能是 low/medium 且 reason 为 null;deny 只能是 medium/high。thinking 关闭;所选模型不能关闭时使用它自己的默认档,不沿用主循环档位。采样沿用 modelOverrides(未配置时不强制 temperature)。prompt cache key 为 <sessionId>:auto_review。请求独立于 AgentLoopRequester,不参与主循环的 cache-break 比较,也不改写基线。一次复核最多 3 次,三次共享默认 30 秒截止(timeout_ms),并透传用户取消。经 isRetryableGenerateError 判定的可重试错误(408、限流 429、5xx、过载、连接错误)和非法 JSON 会退避重试:500ms 起翻倍,最多 25% 抖动,并尊重服务端 retry-after;等待越过截止就不再发下一次。401、配额/余额耗尽的 429、工具调用、授权被改写和取消不重试,也不刷新凭证重发。不按 loopControl.maxAttemptsPerStep 重试。
  • 输入:当前 cwd、Agent 初始化时冻结的 AGENTS.md、压缩后仍在上下文里的用户指令与 subagent 的父级指令(非 fork 子 Agent 同时继承主 Agent 的人类授权指令;导入会话不作为当前用户授权)、历史工具调用(经用户人工批准的调用带 approved: true)、待审工具名称与完整参数,以及目标执行目录的 Git 工作树状态 gitStatus(branch、clean、未提交/未跟踪文件 entries)。用户指令、AGENTS.md 中明确授权的项目工作流和用户已批准的调用作为授权依据;父级 subagent 指令仅在已授权范围内细化委派;未获人工批准的历史工具调用仅作为事实参考。不按条数或字符裁剪,保持稳定缓存前缀;不发送工具输出、tool-result、媒体与面向主 Agent 的工具 description/parameters 元数据。请求超出模型窗口时,这次复核失败,不重试,并触发一次自动上下文压缩。
  • 复核期间用户只是追加了指令时,用新上下文重审一次;指令再次变化、被改写或 cwd 变化时判为失败。
  • 用量按 operation 计入会话,不计入 goal 预算。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
默认配置下的工具审批 无 Auto Review Auto Review flag 仍默认 false;可静态证明只读的 Bash 按下方独立规则直接放行 所有 TUI、print、desktop/web、VS Code、ACP、SDK 用户 关闭实验可停用 Auto Review;需要逐次确认只读命令时配置 ask/deny 规则
只读 Bash 审批 Always Ask / manual 下未被规则放行的 cat、ls 等只读调用仍需人工确认;开启 Auto Review 时仍会送审 完整命令的每个命令段均可静态证明只读时直接执行,underlying 为 approve,不送 Auto Review;此行为不依赖实验 flag 逐次确认只读命令的 TUI、print、desktop/web、VS Code、ACP、SDK 用户 配置对应 ask/deny 规则;敏感文件与 .git 规则仍优先生效
无法静态证明只读的 Bash 按原策略人工审批或 Auto Review 保持原路径:写重定向(除 /dev/null)、命令 / 进程替换、变量赋值、后台执行、here-string、解析失败或未覆盖的命令(包括 find、jq、git)不静态放行 未配置只读命令规则的用户 显式 allow 规则仍可放行;需要逐次确认时配置 ask/deny
实验开启,yolo 下 Always Ask 会问人的调用(如未被规则放行的 Bash、工作区外写入、MCP 工具) 自动执行 先复核:allow 执行;deny 或失败转人工审批;print 模式无人审批时带复核理由拒绝 设置 KIMI_CODE_EXPERIMENTAL_AUTO_REVIEW=1、[experimental] auto_review = true 或总实验开关的 yolo 用户 关闭实验 flag;单次批准或 Approve for this session
实验开启,auto 下同类调用 自动执行 先复核:allow 执行;deny 或失败不执行并返回工具错误,主 Agent 可继续 开启实验的 auto 交互、print/headless、Tower 与 SDK 用户 关闭实验 flag;配置 allow 规则可跳过复核
实验开启,默认放行工具、Git 工作区内写入、用户 allow 规则、本会话已批准、显式 deny — 不复核,结果与关闭实验时一致 无 无需操作
实验开启,yolo 下危险命令识别(rm -rf、shutdown 等) 先识别,命中就人工审批,用户 allow 和本会话批准不生效 不识别:用户 allow 和本会话批准直接执行,其余落到模式放行,底层结果为 ask 时送复核 开启实验、依赖危险命令先问人的 yolo 用户 关闭实验 flag;人工批准单次调用
实验开启,auto 下被用户 allow 规则覆盖的危险命令 自动执行 不变:危险命令检查在 auto 下不生效,用户 allow 规则命中后不复核 无 无需操作
复核期间切换权限模式 — 复核结束后读取当前模式:切到 Always Ask 转人工;auto 与 yolo 之间按最新模式处理 deny 开启实验并在复核等待中切换模式的交互用户 人工批准单次调用
新增 reviewer 提示词 无 按风险与明确授权输出严格 JSON;只有开启实验时发送,主 Agent 的提示词未修改 开启实验的用户 关闭实验 flag
reviewer 规则正文 单段列出 low / medium / high、代码质量边界和授权来源 重排为 Environment、风险规则、Authorization、Decision;medium 仅放行明确覆盖操作、目标和范围的授权,high 始终拒绝;保持单请求和 {risk, decision, reason} 契约 开启实验的 yolo / auto 用户 关闭实验 flag
reviewer 对逐文件撤销助手本会话修改的判断 整文件恢复可能被当成破坏性覆盖,即使它只撤销助手自己的越界改动 仅恢复助手本会话创建或编辑的文件时判为 low-risk allow;涉及用户或其他 Agent 改动时不适用 开启实验并撤回助手改动的 yolo / auto 用户 关闭实验 flag;人工批准单次调用
reviewer 提示词中的代码质量边界 用类型弱化、依赖改为可选、隐藏接线错误等具体例子说明代码质量不属于拒绝范围 概括为代码质量、正确性、架构、风格和无关项目偏好不构成拒绝理由 开启实验的 yolo / auto 用户 关闭实验 flag
reviewer 提示词中的历史授权说明 未获批准的历史调用仅是事实,压缩摘要与未知来源不提供授权 明确历史批准只覆盖其目标与范围,不自动扩展到其他调用;压缩摘要与导入会话不提供授权,用户边界持续有效直至解除 开启实验的 yolo / auto 用户 关闭实验 flag
具体提案与用户确认 Prompt 未声明这条授权路径,Assistant 正文也不进入 reviewer 输入 Prompt 允许该路径;输入结构未扩展,现阶段只在现有授权内容能直接表达时使用,尚无 Assistant 提案配对机制 开启实验的 yolo / auto 用户 关闭实验 flag;由用户直接指明动作、危险目标和范围
reviewer 提示词中的 AGENTS.md 授权规则 项目指令只能收窄允许范围,按 AGENTS.md 要求执行的 worktree 等操作仍可能因用户未当场授权而被拒绝 项目指令中明确授权的工作流可作为放行依据,与主 Agent 遵循的指令一致;无明确授权的删除、覆盖等操作仍需确认 开启实验并在 AGENTS.md 中规定工作流的 TUI、print、desktop/web、VS Code、ACP、SDK 用户 关闭实验 flag
reviewer 提示词中的 medium 放行来源 允许用户或直接父 Agent 指令独立授权操作、目标和范围 用户指令、项目指令与用户已批准的调用(approved: true)可定义授权范围;直接父 Agent 指令只能在已授权范围内细化委派(非 fork 子 Agent 自动继承主 Agent 的人类授权指令) 开启实验并派发 subagent 或人工覆盖复核结果的 TUI、print、desktop/web、VS Code、ACP、SDK 用户 关闭实验 flag
reviewer 模型请求 无 默认优先使用 [secondary_model] 默认模型,未配置时回退主模型;向所选模型所属 provider 发送上方"复核请求的细节"所列内容,并使用所选模型自身的输出预算与能力;用量计入会话 开启实验的用户(包含已配置 [secondary_model] 的用户) 用 [auto_review] model 显式指定模型(如设为主模型别名);关闭实验 flag
复核请求的 thinking 沿用主循环档位。未单独配置复核模型时,主模型的 xhigh 会占满默认 30 秒截止,复核超时后转人工审批 关闭 thinking;模型不能关闭时用它自己的默认档 开启实验、主模型 thinking 档位较高的 yolo / auto 用户 关闭实验 flag;[auto_review] timeout_ms 仍可加长截止时间
复核请求失败 一次 429、5xx 或非法输出即失败,yolo 转人工,auto 拒绝执行 同一截止内最多再试 2 次;耗尽后分流不变。401、配额耗尽 429、取消、授权改写仍一次失败 开启实验、reviewer provider 偶发限流或 5xx 的用户 关闭实验 flag;[auto_review] timeout_ms 可缩短等待
同一轮多条需要复核的命令 逐条复核:下一条要等上一条的复核和审批结束 复核请求并行发出,最多同时 4 个;决策与人工审批在各调用的 waitUntil 阶段等待。每次 legacy starting 决议结束时取消该调用尚未完成的复核,沿用 main 的并发 handler 语义 开启实验、一次发出多条命令的 yolo / auto 用户 关闭实验 flag
复核决策 schema provider 收到根级 anyOf,OpenAI strict Structured Outputs 会拒绝;本地验收拒绝 allow 带理由和 high + allow provider 收到根 object schema,本地验收继续约束交叉组合 开启实验、reviewer 会在 allow 上附理由的用户 关闭实验 flag
配置与遥测 无 [auto_review]、auto_review_decision 与 auto_review.decision 新增 model、timeout_ms;遥测含决策、风险、耗时、触发策略名与模型别名;wire 另持久化 deny reason / failed reason,不保存整段 prompt 读取配置 manifest、分析遥测或排查历史审批的用户 KIMI_DISABLE_TELEMETRY 语义不变
reviewer 拒绝后的人工审批 只显示待执行工具与参数,看不到拒绝理由 ApprovalRequest.approvalDetail 经 node-sdk / klient 传给 TUI 与 SDK 调用方,并经 kap-server 的 approval_detail 透传给 desktop/web。TUI 在原操作上方用 warning 显示标题,理由 dim 且最多两行;desktop/web 在现有审批卡片中展示同一理由。VS Code、ACP 保持原审批卡片 开启实验、需要判断是否覆盖 reviewer 的 TUI、desktop/web 与 SDK 用户 人工批准或拒绝;关闭实验 flag
复核等待中的工具卡片 卡片停在工具参数,看不出正在复核 内联与全屏展开在工具卡片里显示 dim 的 Reviewing…,决策到达或 turn 取消后消失;desktop/web 通过 auto_review 阶段在活动摘要和工具行显示复核状态。print、ACP、SDK 不显示 开启实验的 TUI、desktop/web 用户 关闭实验 flag
全屏 TUI 的复核等待 折叠摘要只显示 Running commands,展开视图也不读取卡片正文中的复核提示 折叠标题保持工作摘要,尾部显示 Reviewing <subject>;展开不重复尾部,只在卡片里显示 Reviewing…。决策或取消后清除 开启实验并使用 fullscreen 的 TUI 用户 关闭实验 flag
主循环模型请求 — None:主循环与 compaction 的请求路径、状态与事件流完全不变;Auto Review 直接复用主线的核心请求器与 resolveCompletionBudget,不恢复已删除的旧请求兼容层 无 无需操作
复核输入的本地裁剪 授权合计 48000 字、单条 8000 字、最近 20 个动作、单条参数 8000 字,超出时丢掉旧内容 不裁剪:压缩后仍在上下文里的指令和全部历史 tool-call 参数原样送出(裁剪 tool-result 与 toolMetadata,在用户人工批准过的 tool-call 上附带 approved: true,并在 <pending_action> 中附带目标目录 gitStatus)。请求超出模型窗口时这次复核失败,不重试,并触发一次自动压缩 开启实验、依赖本地裁剪把超长历史收进复核请求的用户 关闭实验 flag;主循环压缩后复核上下文跟着变短

测试覆盖:

  • permissionGate.test.ts:yolo 下静态 ask 先送 reviewer;模式级放行且 underlying 为 ask 时送审;用户 allow、session 授权、静态 deny 不送审;其他 listener veto 或 final allow 时不复核;静态否决后不再运行后续 permitting hook;yolo / auto 下 deny 与失败的分流、复核期间切换模式、人工推翻 deny 与 print 模式带理由拒绝。
  • permissionPolicyService.test.ts:实验开启时 yolo 下危险命令不识别,用户 allow 与 session 批准先生效,未命中的调用落到模式放行,同一次结果的 underlying 为 fallback-ask;实验关闭时危险命令照旧先问;auto 与 yolo 下同一次遍历的 underlying 分别得到 fallback-ask、default-tool-approve、user-configured-allow。
  • autoReview.test.ts:reviewer 的模型选择、输出预算、thinking 关闭、cache key、严格 JSON、不发送工具输出与 tool-result/toolMetadata、标记用户已批准调用 approved: true、注入目标目录 gitStatus、operation 用量来源与埋点、旧会话无 origin 的用户消息、subagent 父级指令与继承主 Agent 人类授权指令、超长指令与历史参数原样送出、AGENTS.md 快照、prompt 示例与非法输出重试 3 次、429 重试后保留后续决策、401 与配额耗尽 429 不重试、追加指令时立刻重审一次、指令改写失败、截止后不再发起下一次、取消;导入会话不进入授权、pending 兄弟调用不进入历史事实、同批前序调用完成后仍保留。同时最多 4 个复核请求在飞,排队中的请求被取消后不再发出。
  • toolExecutor.test.ts:真实策略链与审批服务下,复核 deny 时工具调用次数为零,allow 时正常执行。同一批的复核在第一条决策返回前就已经全部发出;各调用决议完成后取消其未完成的复核。
  • bash-read-only.ts 与 permissionPolicyService.test.ts:覆盖 32 项只读命令及受限调用、管道与 &&、字面量 heredoc、读取重定向与 /dev/null 输出;写重定向、命令 / 进程替换、变量赋值、后台执行、非法语法、find/jq/git 不静态放行。用户 ask/deny、敏感文件与 .git 检查优先;Auto Review 开启时只读 underlying 为 approve。
  • index.test.ts、forkParity.test.ts:实验开启与默认关闭时 Agent scope 都能通过 AutoReviewFeature 装配。
  • kimi-tui-message-flow.test.ts:内联卡片与全屏折叠尾部、展开卡片都显示 Reviewing,且只出现一次;决策与取消后清除。
  • approval-panel.test.ts:拒绝理由在命令上方,标题为 warning,长理由最多两行。
  • approval-adapter.test.ts:rm -rf/-fr/--recursive 标 recursive delete,rm -f/--force 与 sudo rm -f 标 force delete,裸 rm 不标注。
Validation

本轮 App 迁入与最新主线适配(68de9f2beb):

  • 原 code-app Store Plan mode outputs in ./.kimi-code rather than ~/.kimi-code/session #1240 的 19 个 App 文件已迁入本 PR;apps/desktop/src/renderer 是 desktop / Web 的统一 renderer,不再有独立 apps/web 源码。
  • Auto Review 改用主线现有核心请求器;原分支删除兼容层遗留的 completion-budget.ts 辅助函数同步移除,主循环未改。
  • agent-core-v2 typecheck、desktop pnpm --filter kimi-code-app run typecheck 通过。
  • Auto Review、权限门控、策略链、工具执行、Bash、kap-server conversation 与 SDK 类型共 393 项测试通过;其中 Auto Review 37 项。
  • App 活动摘要、审批映射、会话投影与双语词条共 86 项测试通过。
  • TUI 消息流、审批面板与审批适配共 589 项测试通过。
  • pnpm lint 全部通过:注释检查、oxlint 0 errors / 0 warnings、导入边界、guards、ratchet 与说明文件检查。
  • 最新 main 的 scripts/release.test.mjs 含 10 处从原 code-app 仓库搬入的 node:test 写法,ratchet 按迁移代码规则经 --update --allow-increase 登记计数;toolExecutor.test.ts 已消除的一项同步下调。没有修改发布逻辑,CI 所需的最新 main 已合入。
  • 中英文配置文档已包含实验开关与 reviewer 行为;KAP 指南补充 auto_review 工具阶段与可选 approval_detail。
  • 本轮未重新验证真实模型交互;旧分支的模型交互验证记录保留在下方。
此前迭代的历史验证
  • 本轮已合入最新 main,适配 loop runtime 与并发 tool handler,保留 main 新增的 tool.updated 会话事件;没有恢复旧执行器或 stopBatch 路径。
  • 权限门继续注册在 permitting;共享 legacy emitter 的 final allow 转为 skipPermitting,veto 在 starting 阶段短路;策略评估异常仍产生 permitting hook failed for "...": ... 的工具错误。没有提前启动工具,也没有绕过其他 hook 的放行或否决。
  • agent-core-v2 typecheck 与 build 通过;permissionGate.test.ts 25 个测试通过。permissionPolicyService.test.ts 148 个测试、autoReview.test.ts 37 个测试、Bash 58 个测试通过。
  • 完整 engine 回归共运行三轮。前两轮各有 7938 个测试通过、5 个跳过、1 个失败:第一次是 Tower 的 git update-ref 锁文件竞争,第二次是 loop 的 does not run loop error handlers for aborted turns(恢复快照中用户 history 为空)。第三轮为 7936 个通过、5 个跳过、3 个失败:同一 loop 用例,以及 remote process 的一个 30 秒超时和其后的进程组断言。
  • 基线复现:纯 main 单独运行同一取消 turn 用例,也出现完全相同的 history: [] 恢复快照失败;PR 的同一用例与其一致。纯 main 全量另有一轮 7827 个测试通过、5 个跳过;taskManager 零超时快照也曾在纯 main 并发运行时从预期 running 变为 completed,PR 单 worker 53 个测试通过。本 PR 未修改这些恢复、锁与进程管理实现。
  • 失败文件复查:loop 文件 67 个测试分别在 15 workers 与单 worker 下通过;Tower store.test.ts 228 个测试在 PR 与纯 main 上均通过;remote process.test.ts 23 个测试单独通过。完整 engine 回归没有一轮全绿,以上基线复现与剩余并发波动需要单独处理。
  • 仓库 pnpm lint(type-aware)通过:0 errors,2768 warnings。完整仓库 pnpm run typecheck 也已通过,覆盖 engine、kap-server、SDK、CLI、VS Code 与可视化应用。
  • CI 反馈修复:共享 waitEvent 继续使用 opts.match(event);ACP 的 Bash 审批夹具改用需要审批的 printf 临时文件写入,kap-server 的同类夹具额外保留 stdout 断言。修复后 loop.wait 与 tool adapter 共 7 个测试、ACP 24 个测试、kap-server conversation contract 10 个测试通过。
  • 最终提交 d1a8df3b64 的 CI、Nix Build 与 preview 全部通过;包含 5 个测试分片、完整仓库 typecheck、build、lint、TUI 与 VS Code 测试。
  • 协议适配:kap-server conversation 39 个测试、SDK session-event types 9 个测试通过;两端 typecheck 通过。
  • 真实模型的交互式 yolo 验证:requestKind=auto_review 请求成功,pwd 经 reviewer 放行后执行,没有人工审批;不再出现旁路请求参数的 Unknown encoding 错误。这是引入静态只读放行前的验证;现在 pwd 由静态策略直接放行,不再送 reviewer。
  • 可观测性验证:审批卡片在原命令上方显示 Auto Review failed 与 Review timed out.;同一原因写入 wire.jsonl 的 auto_review.decision,用户拒绝后待审文件未删除。klient contract 与 memory transport 共 41 个测试通过。
  • 全屏提示修复:kimi-tui-message-flow.test.ts、transcript-projection.test.ts、transcript-container.test.ts 共 723 个测试通过;应用 typecheck 与改动文件 lint 通过。全屏展示位置由 kimi-tui-message-flow.test.ts 与 approval-panel.test.ts 的组件渲染覆盖折叠尾部、展开卡片和审批弹窗。上一轮 PTY 验证的是旧文案 Auto Review in progress…,这次没有重跑 PTY。
  • 文档同步:配置与中英文交互文档已在 PR 内手动更新。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 13:26
@changeset-bot

changeset-bot Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5993cc2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@moonshot-ai/kimi-code Minor
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/kap-server Patch
kimi-code-app Patch
@moonshot-ai/kimi-code-sdk Patch
@moonshot-ai/klient Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@7Hanrui

7Hanrui commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@codex review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 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-19T07:13:54.306984Z 5993cc2 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2cdeac76b6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +759 to +763
const thinkingEffort = modelAlias === resolved.modelAlias
? resolved.thinkingLevel
: resolveThinkingEffortForModel(
undefined,
this.config.get<ThinkingConfig>(THINKING_SECTION),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply the review model's thinking effort to its request

When [auto_review].model differs from the primary model, this computes the alternate model's compatible thinkingEffort, but protocolRegistry.request still receives params copied from the primary profile. For example, a thinking-enabled primary model with high effort and a non-thinking review model will raise a thinking configuration error, causing every review to fall back to manual approval or be denied in headless mode. Insert the resolved effort into params before constructing the requester rather than using it only for logging.

Useful? React with 👍 / 👎.

if (message.origin?.kind === 'skill_activation' && message.origin.trigger === 'user-slash') {
return 'human-instruction';
}
if (message.name === 'Agent' || message.name === 'Task') return 'direct-parent-instruction';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize the actual subagent prompt origin

For an Agent subagent, runAgentTurn.ts stores the delegated prompt as a user-role message with origin: { kind: 'system_trigger', name: 'subagent' } and no message.name, so this condition never classifies the prompt as a direct-parent instruction. The reviewer therefore loses the only authorization for a normal non-forked subagent; explicitly delegated medium-risk actions such as deleting or overwriting a file are treated as ambiguous and denied or sent to approval, and cannot run in headless mode. Match the subagent prompt origin instead of relying on message.name.

Useful? React with 👍 / 👎.

Comment on lines +27 to +28
const authorization = retained.flatMap((message) => {
if (authorizationChars >= MAX_AUTHORIZATION_TOTAL_CHARS) return [];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve the newest authorization under the total cap

When retained human instructions exceed 48,000 characters, this traversal spends the budget on the oldest messages and silently drops every later instruction. If an earlier prompt authorizes deletion but the latest prompt says not to delete a particular target, the reviewer sees only the stale grant and can approve the destructive pending action. Select entries from newest to oldest under the cap, then restore chronological order before sending them.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

Comment on lines +108 to +109
const text = boundedText(part.text, remaining);
remaining -= text.length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Stop before slicing with a negative character budget

When one text part exceeds the remaining budget, boundedText appends a truncation marker, so the returned string is longer than remaining and this subtraction makes the budget negative. A subsequent text part is then processed with slice(0, negative), which retains nearly the entire part rather than none; a multi-part user prompt can therefore bypass both authorization-size limits and make reviews overflow or time out. Clamp the budget at zero and stop processing text once it is exhausted.

Useful? React with 👍 / 👎.

decision: { type: 'string', enum: ['allow', 'deny'] },
reason: { type: 'string' },
},
required: ['risk', 'decision'],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make every strict OpenAI schema field required

When [auto_review].model selects an openai or openai_responses provider, its strict structured-output schema is rejected because reason appears in properties but not in required; OpenAI's strict schema subset requires every declared property to be required. The request then fails before inference, so interactive sessions always fall back to approval and headless sessions deny every reviewed tool call. Encode the variants with a supported union or make reason required and nullable, then align DecisionSchema accordingly.

Useful? React with 👍 / 👎.

Comment on lines +61 to +62
const content = boundedContent(message.content, MAX_AUTHORIZATION_ENTRY_CHARS);
return [{ role, content }];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Exclude prompt-hook output from human authorization

For users with a UserPromptSubmit hook, hook output is appended as tagged text parts to the original user-origin message, but authorizationEntry copies every part and boundedContent discards the tag metadata. The reviewer therefore receives automatic hook output labeled as human-instruction; a hook message that requests a deletion or external write can authorize that medium-risk action without the human ever requesting it. Filter isUserPromptSubmitHookPart content or classify it as a non-authorizing constraint/fact.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

Comment on lines +57 to +58
const agentsMd = this.instructions.agentsMd;
const cwd = this.workspace.workDir;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Include the bound environment in review context

For sessions bound to an SSH, Docker, or command environment, the payload includes only workspace.workDir, so a local workspace and a remote target with the same path produce identical ENVIRONMENT input. The reviewer can consequently classify a Write or Bash call as ordinary project-local work and approve it without knowing that it executes across a trust boundary or on a production target. Include the active environment identity/type in the snapshot and invalidate the decision if that binding changes during review.

AGENTS.md reference: AGENTS.md:L28-L28

Useful? React with 👍 / 👎.

Comment on lines +73 to +75
return {
kind: 'ask',
reason: { review_risk: decision.risk },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Show the reviewer rationale in fallback approval

When the reviewer denies an action in an interactive session, the returned ask result carries only review_risk; the model's actionable decision.reason is used only in the later rejection message. AgentToolApprovalService therefore builds a normal approval request from the tool description and arguments without telling the human why the reviewer denied it, even for findings such as credential exposure, while still allowing that human to override the denial. Propagate the rationale into the approval request's displayed action or detail.

Useful? React with 👍 / 👎.

Comment on lines +731 to +733
const modelAlias = overrides.modelAlias ?? resolved.modelAlias;
const baseParams = turnConfig?.params ?? this.profile.resolveRequestParams();
const model = this.modelCatalog.get(resolved.modelAlias);
const model = this.modelCatalog.get(modelAlias);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Attribute override failures to the selected model

When an operation supplies the new modelAlias override and that reviewer request fails, logRequestFailure and trackApiError still resolve the model, provider, protocol, and alias from the primary agent profile rather than from this selected alias. Auto-review failures from a configured provider are therefore recorded against the main model, corrupting provider error rates and making the experiment appear to fail on the wrong backend. Carry the resolved request model into the failure handlers.

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 30853cecc2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

if (configured !== undefined) return configured;
const managed = this.models.findByName(AUTO_REVIEW_MODEL_NAME).find((alias) => {
try {
return this.models.get(alias).providerName === AUTO_REVIEW_PROVIDER;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Match the managed provider's actual ID

When K2.8 is provisioned by the managed login flow, its catalog providerName is managed:kimi-code, so comparing it with kimi-code always rejects the candidate and silently falls back to the main model. This affects users who enable Auto Review without setting [auto_review].model: they do not get the documented managed reviewer, and reviews can fail if their main provider cannot satisfy the strict response schema. Compare against the managed provider ID instead.

Useful? React with 👍 / 👎.

id: AUTO_REVIEW_FLAG_ID,
title: 'Auto Review',
description: 'Review non-read-only tool calls with a separate model in Ask When Needed and Never Ask modes.',
env: AUTO_REVIEW_FLAG_ENV,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Add a changeset for the experimental reviewer

This adds a user-perceivable CLI feature that users can enable with an experimental flag, but the diff contains no .changeset entry, so the next release changelog will omit both the capability and how to enable it. Add an @moonshot-ai/kimi-code changeset that names the Auto Review feature and its enabling flag.

AGENTS.md reference: AGENTS.md:L89-L90

Useful? React with 👍 / 👎.

Comment on lines +36 to +40
const mode = this.modes.mode;
if (!this.flags.enabled(AUTO_REVIEW_FLAG_ID) || (mode !== 'auto' && mode !== 'yolo')) return undefined;
if (EXEMPT_TOOLS.has(context.toolCall.name)) return undefined;
const startedAt = Date.now();
const result = await this.reviewService.review(context);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Revalidate the permission mode after review

When a review starts in auto mode, the existing static policy has already approved the call, but this snapshots mode before a review that can run for up to 120 seconds. If the user switches to manual while it is pending, an allow response still follows the stale auto path and executes without the approval now required by Always Ask; stale mode similarly maps denials to the wrong hard-deny versus approval behavior. Recheck the mode after the await and invalidate or reevaluate the decision when it changes.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

return;
}
if (review?.kind === 'ask') {
event.waitUntil(() => this.toolApproval.requestToolApproval(event, review, this.autoReview.name));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Prevent final allow from bypassing review approval

In yolo Plan mode, a Write or Edit targeting the plan file reaches PlanService, which calls event.allow(); BeforeToolExecuteEmitter then returns immediately without processing pending veto factories. Consequently, when Auto Review denies or fails, this fallback approval is skipped—if the permission gate listener ran first—or the review is skipped entirely if the plan listener ran first, and the reviewer-rejected call executes without asking the user. Ensure the plan-file final allow cannot discard the Auto Review decision.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5f9c1ea407

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +68 to +69
if (message.origin?.kind === 'user' || message.origin?.kind === 'plugin_command') {
return 'human-instruction';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Treat originless legacy user messages as human instructions

When Auto Review is enabled on a resumed legacy session, user messages written before prompt origins were recorded have origin === undefined; replay and undo code explicitly treat these as real user prompts, but this branch assigns them no authorization role. An earlier task instruction authorizing a deletion or overwrite is therefore omitted, causing the reviewer to reject a legitimate follow-up and Never Ask mode to hard-deny it. Treat an originless user-role message as a human-instruction, matching the existing legacy replay semantics.

AGENTS.md reference: AGENTS.md:L110-L112

Useful? React with 👍 / 👎.

Comment on lines +54 to +58
if (review?.kind === 'ask') {
const staticAsk = evaluation?.result.kind === 'ask' ? evaluation.result : undefined;
const result = staticAsk ?? review;
const origin = evaluation?.result.kind === 'ask' ? evaluation.policyName : this.autoReview.name;
const resolved = await this.toolApproval.requestToolApproval(event, result, origin);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reuse the existing Plan exit approval

In Ask When Needed with an active nonempty plan, a reviewer denial or timeout makes this call open an approval request immediately, while AgentPlanService has independently registered its ExitPlanModeReview as a pending veto factory. After the user approves this fallback, the emitter runs that factory and presents the same plan approval a second time, so one ExitPlanMode call requires two approvals and records approval telemetry twice. Combine the reviewer fallback with the pending Plan review instead of issuing a separate prompt.

AGENTS.md reference: AGENTS.md:L110-L112

Useful? React with 👍 / 👎.

}
if (result.kind === 'approve') {
event.pass(result.executionMetadata);
const review = await this.autoReview.evaluate(event);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor approve-for-session for reviewer fallbacks

In Ask When Needed, when the reviewer denies and the user selects Approve for this session, the approval service records context.execution.approvalRule and reports approved_for_session. The next matching call is therefore statically approved by SessionApprovalHistoryPermissionPolicyService, but this unconditional review runs again; because approval results are absent from buildReviewMessages and historical calls are explicitly non-authorizing, the reviewer denies again and presents another prompt. Either carry the session approval into reviewer authorization or prevent reviewer fallback prompts from offering and recording a session-scoped approval.

AGENTS.md reference: AGENTS.md:L110-L112

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 98e65bfa65

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@7Sageer
7Sageer marked this pull request as ready for review November 4, 2026 06:04
@pkg-pr-new

pkg-pr-new Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@5993cc2
npx https://pkg.pr.new/@moonshot-ai/kimi-code@5993cc2

commit: 5993cc2

Keep one static-plus-review decision for both permission entry points, leave turn-context measurement untouched by auto review requests, and require a nullable reason in the strict decision schema.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a38e766068

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if (reviewed === undefined) return;
if (reviewed.result.kind === 'ask') {
const ask = reviewed.result;
const resolved = await this.toolApproval.requestToolApproval(event, ask, reviewed.origin);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Defer Auto Review approval until Plan guards run

When Auto Review is active in Plan mode and a Write or Edit targets anything other than the current plan file, this awaits the reviewer fallback before the Plan guard can veto. If the user approves a reviewer denial or failure, the approval can even be recorded for the session, although AgentPlanService.guardToolExecution will still reject the write. The previous event.waitUntil deferred approval until after listeners, allowing the Plan veto to skip it; defer this fallback too so users are not prompted to approve an action that cannot run.

AGENTS.md reference: AGENTS.md:L110-L112

Useful? React with 👍 / 👎.

`PROJECT_INSTRUCTIONS\n${JSON.stringify({
role: 'constraint',
paths: instructionPaths ?? [],
content: instructions ?? '',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound project instructions in reviewer requests

When [auto_review].model selects a model whose context limit is below the combined review prompt, this adds the complete AGENTS.md snapshot without a bound. loadAgentsMdForRoots only warns when the total exceeds 32 KiB, so a large instruction set can make each review fail; in auto mode that failure denies every non-exempt tool call. Bound or truncate the instruction content before sending it to the reviewer.

Useful? React with 👍 / 👎.

}

async evaluate(context: ResolvedToolExecutionHookContext): Promise<PermissionPolicyResult | undefined> {
if (!this.enabled || EXEMPT_TOOLS.has(context.toolCall.name)) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict exemptions to built-in read-only tools

When an integration registers a user tool named Read, the registry allows it to replace the built-in tool, but this name-only exemption skips Auto Review. The user tool dispatches to host-provided execution, and the default policy also approves Read, so its side effects can run without review in auto or yolo mode. Exempt only known built-in read-only registrations or reject reserved-name collisions.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

Keep the default permission gate on main's two-phase flow so a static ask
waits for every listener before prompting, and run the reviewer inside the
same deferred phase. Move the review/static result mapping into the auto
review feature, drop the plan guard special case, mark session approvals
explicitly, and replace the implicit temperature/requestKind coupling in the
requester with explicit sampling and detached overrides. Reviewer requests
now send the selected model's thinking effort.
@7Hanrui

7Hanrui commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e2b0abceb5

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +5 to +8
{"risk":"low","decision":"allow"}
{"risk":"medium","decision":"allow"}
{"risk":"medium","decision":"deny","reason":"..."}
{"risk":"high","decision":"deny","reason":"..."}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align allow examples with the required response schema

When a configured reviewer backend does not strictly constrain generation from responseFormat, the prompt tells it to return either {"risk":"low","decision":"allow"} or {"risk":"medium","decision":"allow"}, but DecisionSchema requires reason: null and explicitly rejects those exact examples. A reviewer that follows the prompt therefore turns every allow into a failed review, which denies the call in Never Ask mode or unnecessarily prompts in Ask When Needed mode; include "reason":null in both allow examples and clarify that null is required.

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 74a83a716e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

name: context.toolCall.name,
description: tool?.description ?? '',
parameters: tool?.parameters ?? {},
arguments: context.args,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Bound the pending action payload

When Auto Review is enabled, calls with large arguments—such as Write with a generated file containing hundreds of kilobytes—place the complete context.args into the reviewer prompt without any limit. This can exceed the selected review model's context window, making the review fail and causing Never Ask mode to deny an otherwise valid operation (or Ask When Needed to present an unnecessary fallback approval); truncate or otherwise bound large pending arguments while retaining the security-relevant fields.

Useful? React with 👍 / 👎.

tools: overrides.tools === undefined ? undefined : [...overrides.tools],
messages: [...messages],
responseFormat: overrides.responseFormat,
detached: overrides.detached === true,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep detached reviews out of loop request records

For every Auto Review request, detached is honored only by the token-counting and cache-measurement guards; onAttempt still calls recordRequest, which dispatches a durable llm.request with kind: "loop" and may also persist an empty llm.tools_snapshot. Sessions therefore expose internal reviewer calls as ordinary agent-loop requests to wire consumers, and the v2 persistence fold at human/persist/v2/fold.ts:628-630 treats their provider/model as the latest loop model. Skip durable loop recording for detached operations or add an explicit operation kind so these records cannot be mistaken for agent steps.

AGENTS.md reference: AGENTS.md:L122-L124

Useful? React with 👍 / 👎.

Route auto review through a shadow policy evaluation that skips the
mode-level approvals, and send review requests through a standalone
model requester with retries and credential recovery instead of the
agent loop requester.
@7Hanrui

7Hanrui commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d9aa2be4be

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

name: context.toolCall.name,
description: tool?.description ?? '',
parameters: tool?.parameters ?? {},
arguments: context.args,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid sending secrets to a second reviewer provider

When Auto Review is enabled and a pending call embeds a credential in its arguments—for example, a Bash command or an MCP argument—this serializes the complete secret into the review request. Because the reviewer defaults to managed K2.8 even when the main model uses a different or self-hosted provider, the credential is silently disclosed to an additional provider before the reviewer can classify that disclosure as high risk. Redact secret-bearing values or constrain review to the same provider trust boundary.

Useful? React with 👍 / 👎.

Comment on lines +42 to +43
description: tool?.description ?? '',
parameters: tool?.parameters ?? {},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Treat tool metadata as untrusted reviewer input

For MCP and user tools, the tool provider controls description and parameters (for example, createMcpTool copies both directly), but these fields are inserted into the reviewer's user message without an untrusted-data label. The system policy only warns about instructions in historical facts and tool output, so malicious metadata such as an instruction to return allow can influence the decision; in Never Ask mode that silently executes the call without human approval. Delimit this metadata as untrusted and explicitly instruct the reviewer never to follow instructions contained in it.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

projectInstructions.agentsMd,
projectInstructions.agentsMdPaths,
cwd,
this.tools.resolve(context.toolCall.name),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Review the tool instance that will execute

When an MCP or plugin hot reload replaces or removes a tool after preflight but before the deferred review starts, this registry lookup returns the new registration (or undefined), while context.execution and context.tool still refer to the original tool that will actually run. The reviewer can therefore judge a different description and schema, potentially allowing the old side-effecting implementation based on a benign replacement or denying a valid call because its metadata disappeared. Pass context.tool to buildReviewMessages so the reviewed metadata belongs to the resolved instance being executed.

Useful? React with 👍 / 👎.

Comment on lines +82 to +89
if (message.role === 'tool') {
if (message.toolCallId === pendingCallId) return [];
return [{
kind: 'tool-result',
role: 'fact',
toolCallId: message.toolCallId,
isError: message.isError === true,
}];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve trusted human interaction responses

When the user answers AskUserQuestion or rejects an approval with corrective feedback, that human input is encoded in a tool result, but this projection retains only the call ID and isError flag and authorizationEntry ignores tool messages entirely. The reviewer therefore cannot see a newly selected scope such as “delete generated caches only”; the following action is denied or prompts again in Ask When Needed mode and is hard-denied in Never Ask mode. Preserve responses from trusted interaction surfaces with distinct provenance while continuing to exclude arbitrary tool output.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f473f90eb

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

): OpenedToolCall | undefined {
if (call.kind === 'rejected') return undefined;
const execution = Promise.resolve().then(() => call.tool.resolveExecution(call.args));
const event = execution.then((resolved) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Observe each opened call's rejection immediately

When a multi-tool response has an earlier call waiting for approval and a later async resolveExecution rejects, this success-only .then leaves opening.event rejected and unobserved until the sequential preparation loop reaches its finally; the CLI's unhandled-rejection handler exits before prepareToolCall can return the intended resolution-failed result. Attach a rejection handler when creating the event promise while preserving the rejection for later handling.

Useful? React with 👍 / 👎.

# Conflicts:
#	packages/agent-core-v2/docs/wire-manifest.d.ts
#	packages/agent-core-v2/src/agent/loop/requester.ts
#	packages/agent-core-v2/src/agent/permissionGate/permissionGateService.ts
#	packages/agent-core-v2/src/agent/toolExecutor/beforeToolExecuteEvent.ts
#	packages/agent-core-v2/src/agent/toolExecutor/toolExecutorService.ts
#	packages/agent-core-v2/src/events.ts
#	packages/agent-core-v2/test/agent/permissionGate/permissionGate.test.ts
#	packages/agent-core-v2/test/agent/toolExecutor/toolExecutor.test.ts
#	packages/agent-core-v2/test/tool/tool.test.ts
#	packages/kap-server/src/services/conversation/conversationFeed.ts
#	packages/kap-server/test/services/conversation.test.ts
#	packages/node-sdk/test/session-event-types.test.ts
@7Sageer 7Sageer changed the title feat(agent-core-v2): add experimental auto review feat(agent-core-v2): add experimental auto review and read-only Bash approvals Nov 11, 2026
@7Hanrui

7Hanrui commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b2d5af406

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

try {
const pathClass = lease.environment.host?.pathClass;
if (pathClass === undefined) return undefined;
const cwd = this.workspace.workDir;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve paths against the Bash call's effective cwd

When a Bash call supplies its own cwd, this still resolves every operand against the session workspace. For example, { command: "cat config", cwd: ".git" } executes against .git/config, but the Git-control policies and this read-only policy inspect config as though it were under the workspace root, so the call is silently approved even in Always Ask mode. Resolve and validate paths against the same effective cwd used by BashTool.execution.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

break;
}
if (text === '--version' || text === '--help') continue;
if (/^--[a-zA-Z][a-zA-Z0-9-]*=/.test(text)) continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject reads whose effective inputs are not inventoried

On GNU systems, diff --from-file=/home/me/.ssh/id_rsa /dev/null reaches this branch, which drops the path-valued option and reports only /dev/null; diff --help documents --from-file=FILE1 as comparing that file to every operand, and differing contents are printed. The same incomplete-inventory problem affects recursive grep, where grep -R TOKEN . records only . while reading descendant .env or key files. Because this policy also runs in Always Ask mode, the sensitive-file guard never sees the actual inputs and the command is silently approved; reject such options and recursive searches unless all effective inputs can be checked.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d1a8df3b64

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

return undefined;
}
});
if (paths.some((path) => path === undefined || isSensitiveFile(path))) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Block Kimi credential files from read-only approval

In Always Ask mode, cat ~/.kimi-code/credentials/<name>.json reaches this check with a canonical path, but isSensitiveFile does not recognize the documented Kimi credential directory when the filename is an ordinary JSON name. The new policy therefore returns approve and sends stored OAuth credentials through Bash output without confirmation, whereas before this commit the call reached fallback-ask; explicitly protect the Kimi data-root credential/config paths or avoid auto-approving reads outside the workspace.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

if (typeof context.args !== 'object' || context.args === null) return undefined;
const command = (context.args as { readonly command?: unknown }).command;
if (typeof command !== 'string') return undefined;
const readOnly = analyzeBashReadOnly(this.bashParser.parse(command, PARSE_OPTIONS));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject Bash continuations before approving paths

For an operand such as cat .e\<newline>nv, Bash removes the continuation and reads .env, while the repository parser treats the continuation as a separator and this analyzer inventories the harmless paths .e and nv. The sensitive-file check is consequently bypassed and the call is silently approved; the same construction can hide .git paths. Reject or shell-normalize continuations before treating the parsed operands as the command's effective inputs.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

if (name === 'ifconfig') {
return operands.length === 1 && /^[a-zA-Z]/.test(operands[0]!) ? paths : undefined;
}
if (!READ_ONLY_COMMANDS.has(name)) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Verify the executed command before declaring it read-only

When the bound shell is Bash and the inherited BASH_ENV defines a function named cat, a call such as cat harmless passes this textual whitelist even though the function can perform arbitrary writes before reading the file. BashTool starts the shell with the process environment inherited, so this is the callable that actually executes; before this policy the call still required confirmation in Always Ask mode. Sanitize shell startup hooks or resolve the effective command before granting read-only approval.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

if (paths.some((path) => path === undefined || isSensitiveFile(path))) return undefined;
const marker = lease.environment.fs === undefined
? null
: await findGitWorkTree(lease.environment.fs, cwd);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip the Git probe for pathless read-only commands

For pathless commands such as echo hello, pwd, or bare ls, readOnly.paths is empty, but this still awaits findGitWorkTree, which performs an uncancellable filesystem probe for every ancestor directory. On a slow or wedged SSH/container filesystem, an otherwise immediate command can therefore block indefinitely despite turn cancellation; return approve before probing when there are no paths, and make the remaining probe cancellation-aware.

AGENTS.md reference: AGENTS.md:L110-L112

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 39b2d5c4b3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

: path.startsWith('~/')
? `${lease.environment.host!.homeDir}/${path.slice(2)}`
: path;
return canonicalizePath(expanded, cwd, pathClass);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve symlinks before approving read-only Bash

When an operand is a symlink, canonicalizePath only normalizes its lexical path while Bash follows the link. For example, a workspace link named harmless that targets .git/config or a credential file makes cat harmless pass both the sensitive-file and Git-control checks and receive approve; before this policy it reached the fallback prompt in Always Ask mode. Resolve each operand through the bound environment filesystem and validate the real target, failing closed when it cannot be resolved, so symlinks cannot silently bypass approval.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f0e24f5923

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +18 to +20
Reverting the agent's own session edits file-by-file is low-risk local work.
Allow when the pending action only restores files the agent previously created
or edited in this session and does not discard user or other agents' changes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Verify ownership before allowing file reverts

When a user or another agent modifies a file after this agent edited it, the reviewer cannot establish the new ownership condition: context.ts:38-52 supplies only historical tool arguments and the current Git status, with no before/after content or change provenance. A pending git checkout -- <file> therefore looks identical whether it discards only the agent's edit or also newer human work, yet this instruction can classify it as low risk and silently approve irreversible data loss in Never Ask mode; only grant this exception when ownership is tracked and verified, otherwise keep the revert approval-gated.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

if (['head', 'tail'].includes(name) && ['-n', '-c'].includes(text)) index++;
continue;
}
paths.push(text);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reject unexpanded globs before granting read-only approval

When Bash runs an unquoted operand such as cat .??* in a workspace containing .env, the shell expands the glob and reads .env, but this branch records only the literal .??*; the policy then canonicalizes and checks that literal string, so neither the sensitive-file check nor the Git-control-path check sees the files that will actually be opened. In Always Ask mode this silently exposes matching credentials without a prompt; reject glob metacharacters for every analyzed command or expand and validate every match in the bound environment before approving.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

Comment on lines +96 to +97
if (origin.kind === 'user' || origin.kind === 'plugin_command') return 'human-instruction';
if (origin.kind === 'skill_activation' && origin.trigger === 'user-slash') return 'human-instruction';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep generated slash-command bodies out of human authorization

When a user invokes a project/plugin command or user-activatable skill whose stored body names a destructive action that the user did not type, these branches classify the entire generated message as human-instruction. skillService.ts:79-93 embeds the skill body and pluginCommandService.ts:48-70 submits the expanded plugin body, while the review policy permits human instructions to authorize medium-risk work; a third-party command can therefore silently authorize its own destructive call in Never Ask mode merely because the user invoked it. Preserve only user-authored arguments or accompanying content as authorization and mark generated command/skill bodies as non-authorizing context.

AGENTS.md reference: AGENTS.md:L130-L132

Useful? React with 👍 / 👎.

…iew-gui-migration

# Conflicts:
#	apps/kimi-code/src/tui/utils/transcript-items.ts
#	docs/en/configuration/config-files.md
#	docs/zh/configuration/config-files.md
#	packages/agent-core-v2/docs/config-manifest.toml
#	packages/agent-core-v2/src/agent/loop/requester.ts
#	packages/agent-core-v2/src/llm-adapter/model/completion-budget.ts
#	packages/agent-core-v2/src/tool/executor/tool-executor.ts
#	packages/agent-core-v2/test/agent/toolExecutor/toolExecutor.test.ts
@7Hanrui

7Hanrui commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68de9f2beb

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +48 to +50
pending_action: sectionJson({
name: context.toolCall.name,
arguments: context.args,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Redact secrets before sending tool arguments to the reviewer

When Auto Review uses a secondary model backed by a different provider, this sends the pending tool arguments verbatim across that additional trust boundary. For example, reviewing Write for an .env file transmits its credential-bearing content, and actionEntries similarly includes every historical call's raw arguments; the sensitive-file gate therefore triggers the very disclosure it is intended to review. Redact secret-bearing values before constructing the review messages, or constrain review requests to the main model's trust boundary.

Useful? React with 👍 / 👎.

Comment on lines 220 to 223
const DANGER_PATTERNS: Array<{ pattern: RegExp; label: string }> = [
{ pattern: /\brm\s+(-[a-zA-Z]*[rRfF][a-zA-Z]*|--recursive|--force)/i, label: 'recursive delete' },
{ pattern: /\bsudo\b/i, label: 'sudo' },
{ pattern: /\brm\s+(-[a-zA-Z]*[rR][a-zA-Z]*|--recursive\b)/, label: 'recursive delete' },
{ pattern: /\brm\s+(-[a-zA-Z]*[fF][a-zA-Z]*|--force\b)/i, label: 'force delete' },
{ pattern: /\b(curl|wget)\b[^|]*\|\s*(sh|bash|zsh)\b/i, label: 'pipe to shell' },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore the sudo danger classification

For TUI approvals whose only recognized hazard is privilege escalation, such as sudo apt install ..., removing the sudo pattern makes detectDanger return no warning even though the desktop detector still classifies the same command as sudo. The changeset only declares the corrected distinction between forced and recursive removal, so preserve the existing sudo entry after the two rm patterns.

AGENTS.md reference: AGENTS.md:L188-L190

Useful? React with 👍 / 👎.

Comment on lines +81 to +84
const command = (context.args as { readonly command?: unknown }).command;
if (typeof command !== 'string') return undefined;
const readOnly = analyzeBashReadOnly(this.bashParser.parse(command, PARSE_OPTIONS));
if (readOnly === undefined) return undefined;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep persistent Bash tasks behind approval

When a read-only-looking command is submitted with run_in_background: true and disable_timeout: true, this policy examines only command and silently approves the call even in Always Ask mode. For example, tail -f app.log then starts an unbounded background process without confirmation; spawning a persistent task is a separate effect from reading the file. Decline read-only approval when the Bash arguments request background or timeout-free execution.

AGENTS.md reference: AGENTS.md:L208-L210

Useful? React with 👍 / 👎.

Comment on lines 132 to +135
abandon({ isError: true, output: 'Aborted before command started' });
};
return {
accesses: readOnly?.paths.map((path) => ({ kind: 'file', operation: 'read', path })),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Canonicalize Bash read paths before scheduling

For a relative read such as cat notes.txt, this publishes the scheduler access as notes.txt, while Write and Edit publish the same target as an absolute path such as /workspace/notes.txt. ToolAccesses.conflict only normalizes separators and case, so a model response containing both calls starts them concurrently; the Bash result can nondeterministically observe the old or new contents even though Bash previously used the all-resources fallback and was serialized. Resolve these paths against the Bash call's effective cwd before exposing them as accesses.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5993cc2cf9

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

private setToolAutoReviewing(toolCallId: string, reviewing: boolean): void {
const { streamingUI } = this.host;
streamingUI.flushNow();
streamingUI.getToolComponent(toolCallId)?.setAutoReviewing(reviewing);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Buffer review events until the tool card is registered

When Auto Review runs during the permission gate, auto_review.started arrives before the executor announces tool.call.started, which is delayed until execution can begin. No ToolCallComponent exists yet, so this lookup drops the start event; the decision event is dropped too, and the card never shows review progress. Buffer the state by call ID and apply it when handleToolCall registers the component.

AGENTS.md reference: AGENTS.md:L111-L115

Useful? React with 👍 / 👎.

This branch has not been deployed

No deployments
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.

3 participants