Skip to content

feat(agent-core-v2): add experimental auto review - #4655

Merged
7Sageer merged 112 commits into
mainfrom
auto-review
Nov 26, 2026
Merged

7Sageer merged 112 commits into
mainfrom
auto-review

Conversation

@7Sageer

@7Sageer 7Sageer commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Screenshots / Recordings

复核满 3 秒仍未出结果时,全屏折叠视图在尾部显示状态(3 秒内结束的不显示):

  Running commands
  └ Reviewing echo hi

复核未通过后的审批弹窗。标题写"未通过"而不是"已拒绝",因为是否批准仍由用户决定:

  ▶ Run this command?

  Auto Review didn't approve · medium risk
  Creating remote resources was not explicitly authorized.
  $ ssh example.test -- reboot

Requirement or Bug

Ask When Needed(yolo)和 Never Ask(auto)省掉了人工确认,Bash 和 MCP 调用会直接执行。本 PR 加入默认关闭的实验能力 Auto Review:Always Ask 下会问人的 Bash / MCP 调用,先交给一个独立模型判断一次。其他内置工具(Edit、Write 等)不参与。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

核心思路:是否送审,看 Always Ask 会不会问人。权限模式改成 PermissionPolicy.evaluate(context, mode) 的入参,同一条策略链换成 manual 再求值一次,就是 Always Ask 的结果,不用另外维护名单。复核直接在权限门的 permitting 钩子里进行,主循环请求路径不变。

flowchart TD
    A["Bash / MCP 调用(实验开启)"] --> B{"实际结果是 ask,或按 Always Ask 求值是 ask?"}
    B -- "否" --> G["沿用原结果"]
    B -- "是" --> C{"实际求值命中用户显式 ask 规则?"}
    C -- "是" --> G
    C -- "否" --> H["LLM 复核"]
    H -- "allow" --> E["执行"]
    H -- "deny / 失败" --> J{"复核结束时的模式"}
    J -- "yolo" --> K["转人工审批,附复核理由"]
    J -- "auto" --> L["不执行,返回工具错误"]
Loading

因为判据就是 Always Ask 的结果,显式 deny、只读 Bash、用户 allow 规则、本会话已批准都不送审。唯一的例外是危险命令:开启实验时危险命令策略排在 allow 之前,kimi -p 下也启用(关闭实验时非交互宿主仍与 main 一致跳过),所以被 allow 覆盖的危险命令也会送审。

模块 Scope 职责
SessionAutoReviewService Session 配置校验、全会话 4 路并发、AGENTS.md 缓存、独立请求器发请求与重试
AutoReviewService Agent 组装复核输入、子 Agent 祖先授权快照、已批准调用状态、授权漂移重审
autoReviewGate.ts — 触发判断与分流,经 registerReviewer 挂到权限门;权限门不依赖 features/autoReview

reviewer 的输入包括:cwd、AGENTS.md、用户指令(每条带 replyTo,即它所回复的 Agent 消息末尾 2000 字符,让 reviewer 知道用户说"可以"时确认的是什么)、有副作用或经人工批准的历史调用、待审参数,以及删文件或改 git 状态的 Bash 才附带的 gitStatus。Prompt 规则:low 放行,medium 需要明确授权,high 始终拒绝;replyTo、工具输出和 Agent 声称的同意都不算授权。

KAP 没有扩展 tool_call.stage 枚举,而是新增可选字段 tool_call.auto_review,旧客户端不受影响;复核结论以 approval_detail { outcome, risk?, reason } 经 WS 和 REST 下发,标题文案由共享的 formatApprovalReviewTitle 统一生成。

关键决策

决策 选择 没选 理由
送审范围 只限 Bash 与 mcp__* 所有工具 文件编辑保持现有语义,新增内置工具默认不受影响
Always Ask 的结果 模式作为入参重新求值 给策略打标记再跳过 跳过名单会漏掉"auto 下关闭危险命令检查"这类差异
请求通道 独立请求器 复用主循环 requester 不污染主循环的对话前缀、工具快照和 token 计数
thinking 显式 [auto_review].effort,否则取复核模型的默认档 强制关闭;跟随主循环 只有一个阶段,不影响缓存;关掉会让模型不经推理就下结论
祖先授权快照 新建/fork 子 Agent 时写入 wire,恢复时回放 每次恢复按祖先当前历史重算 祖先之后的对话、压缩或 /undo 不应改变子 Agent 的授权依据

阅读指南(packages/agent-core-v2/src/features/autoReview/):autoReviewGate.ts(何时送审、怎么分流)→ reviewService.ts 与 context.ts(输入组装、快照、漂移)→ sessionReviewService.ts(模型、并发、重试)→ auto-review-policy.md(prompt)。策略签名改动、字段透传、manifest、文档和测试可略读。

复核请求的细节
  • 模型:[auto_review].model > [secondary_model] 默认模型 > 主模型;借用 [secondary_model] 时连同它的 default_effort。无效别名或不支持的档位报 CONFIG_INVALID。
  • 截止与重试:默认 30 秒(timeout_ms),瞬时错误和非法 JSON 最多尝试 3 次;401、配额耗尽、Retry-After 超出剩余截止时间或上下文溢出不重试。溢出时只让本次复核失败,不压缩主 Agent 上下文。
  • 漂移:请求返回时授权或 cwd 有变化,用最新上下文重审一次,再变就判失败。
  • 用量计入会话,不计入 goal 预算。

Behavior Changes and Affected Users

除第一行外,都只在开启实验后出现(KIMI_CODE_EXPERIMENTAL_AUTO_REVIEW=1、[experimental] auto_review = true 或 KIMI_CODE_EXPERIMENTAL_FLAG=1);关闭实验就是所有行的退路。

Behavior Before After Who relies on the old behavior Escape hatch
默认配置 — 不变:不发复核请求、不写快照,非交互宿主继续跳过危险命令询问 所有用户 —
yolo 下 Always Ask 会问人的 Bash / MCP 自动执行 先复核;deny 或失败转人工,print 模式带理由拒绝 yolo 用户 人工批准
auto(含 kimi -p)下同类调用(含命中的 ask 规则) 自动执行 先复核;deny 或失败返回工具错误,提示主 Agent 请用户确认 auto 交互、headless、Tower、SDK 用户 allow 规则(危险命令除外)
危险命令,包括被 allow 覆盖的 yolo 一律问人;auto 自动执行 一律先复核;yolo 下 allow 就执行,不再问人 依赖"危险命令必问人"的 yolo 用户;用 allow 放行危险命令的 auto 用户 无
其他内置工具;yolo 下的用户显式 ask 规则 — 不送审,与关闭实验时一致 — —
复核模型请求 无 向复核模型的 provider 发送上述输入,用量计入会话;新增 [auto_review] 配置节 开启实验的用户 [auto_review].model / effort / timeout_ms
审批卡片与工具卡片 无复核信息 审批卡片显示复核标题与理由;复核满 3 秒显示 Reviewing… TUI、desktop/web、VS Code、ACP、SDK、KAP 客户端 人工批准或拒绝
wire、状态与遥测 — 新增 auto_review.* 记录与可回放状态,manifest 只增不改,旧版本跳过未知记录;触发复核的调用 policy_name 记为 auto-review 读 manifest、分析遥测的用户 —

测试:permissionGate.test.ts 与 permissionPolicyService.test.ts 覆盖送审范围、分流和危险命令;autoReview.test.ts 覆盖输入组装、快照、模型解析、重试与漂移;kap-server、klient、node-sdk、TUI、ACP、app-components 覆盖接口与界面。

删除了 main 上的 4 个用例:permissionGate.test.ts 中测 authorize() 的 3 个(该方法没有调用方,已改为 registerReviewer,同样情形由同文件 fireBeforeExecute 的用例覆盖);permissionPolicyService.test.ts 的 does not load the dangerous command policy for non-interactive hosts(由 keeps dangerous command detection for manual re-evaluation on non-interactive hosts 覆盖关闭实验跳过、开启实验拦截及手动重评)。

验证:基于最新 main(e3b19047a7)在 macOS 上跑通整仓 pnpm lint、pnpm run check:duplication、受影响包构建与 tsc 类型检查,以及受影响测试套件;此前亦在 Linux 上跑过相关测试文件。未验证:Windows;精简 prompt 后 reviewer 的真实决策质量。

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: 1189e1d

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
kimi-code-app Patch
@moonshot-ai/agent-core-v2 Patch
@moonshot-ai/kap-server 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-25T16:24:17.993624Z 1189e1d Manual request
ℹ️ 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@1189e1d
npx https://pkg.pr.new/@moonshot-ai/kimi-code@1189e1d

commit: 1189e1d

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 👍 / 👎.

@7Hanrui

7Hanrui commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@codex review

# Conflicts:
#	packages/acp-server/src/approval.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 62f5c497c4

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

@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: 18fbae2fd6

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

Comment on lines +184 to +186
const latestHistory = this.loop.history();
if (latestHistory !== snapshot.history) {
const drift = detectAuthorizationDrift(snapshot.authorization, this.authorizationOf(latestHistory));

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 review results after project instructions change

If an AGENTS.md instruction authorizing the pending action is removed while the review model call is running, snapshot.messages still contains the old instructions. This completion path rechecks the working directory and chat history, but not the instructions, so it can still accept an allow based on revoked guidance. The new onDidChange handler only refreshes the cache for later snapshots; compare or invalidate the in-flight snapshot before using its result.

AGENTS.md reference: AGENTS.md:L211-L213

Useful? React with 👍 / 👎.

Add [auto_review].effort so the review effort can differ from the main
agent without registering a model variant. It is validated with the same
checks as [secondary_model].default_effort, which now share one helper.

When the reviewer borrows the [secondary_model] default model, it also
borrows that section's default_effort instead of falling back to the
model entry's own default.

@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: db21a7af29

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

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.

P1 Badge Stop self-authored instructions from approving actions

When Auto Review is enabled in auto or yolo mode, an agent can use the unreviewed Write tool to change a project AGENTS.md and authorize a later workflow. This passes the changed text to the reviewer as a constraint, and the review policy allows project instructions to authorize medium-risk actions, so a later Bash or MCP deployment or publish call can be silently approved based on authorization the agent manufactured. Only treat independently trusted, user-established project instructions as authorization, or track their provenance.

AGENTS.md reference: AGENTS.md:L213-L213

Useful? React with 👍 / 👎.

Fold case-specific sentences into the rules they refine and drop text
that repeats another rule or describes inputs the reviewer never sees.
Name the history roles once so the rules can refer to the labels that
appear in the request data.
Align Auto Review with the Workspace -> Project rename, refresh the KAP contract digest, fix the auto_review doc anchors, and drop an unrelated BROWSER_TOOL_NAME display-kind check.
@7Hanrui

7Hanrui commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@codex review

Show the "Reviewing" hint only after a review has run for 3 seconds, so
reviews that finish quickly no longer flash it. This applies to the TUI
tool card and fullscreen tail, and to the desktop and web tool rows and
activity summary.

Title the approval prompt after a denial "Auto Review didn't approve"
instead of "recommends rejecting": the user still decides whether to
approve, and the new wording states the verdict without implying the
action was blocked.

@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: 484b868566

ℹ️ 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 +49
await reviewService.review(context, askEval.policyName),
flags.enabled(AUTO_REVIEW_FLAG_ID) ? modes.mode : 'manual',

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 Re-evaluate permission policies after review

When permission rules change while the model review is in flight—for example, another client adds a session-runtime deny or config reload introduces a deny rule—this continuation uses the original evaluation and only refreshes the flag and mode. Since AgentPermissionRulesService.rules reads live state/config, a new deny would apply to a fresh evaluation, but a reviewer allow here still resolves to approve and silently executes the call. Re-run the current policy chain after review and let a new deny or explicit ask take precedence.

AGENTS.md reference: AGENTS.md:L211-L213

Useful? React with 👍 / 👎.

Comment on lines +197 to +200
} catch (error) {
context.signal.throwIfAborted();
outcome = deadline.signal.aborted
? { decision: 'failed', reason: deadline.timedOut() ? 'Review timed out.' : 'Review cancelled.' }

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 Emit a terminal review event when cancellation aborts

When the user cancels while Auto Review is running, this rethrow exits review() before AutoReviewCompleted is dispatched. Consumers set their review state on auto_review.started and clear it only on auto_review.decision, so the recorded KAP tool item can retain auto_review: true and event consumers never receive a matching terminal transition. Dispatch the failed/cancelled completion during cleanup before propagating cancellation.

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

Useful? React with 👍 / 👎.

...(bootstrap.args.nonInteractive
? []
: [this.instantiation.createInstance(DangerousCommandAskPermissionPolicyService)]),
this.instantiation.createInstance(DangerousCommandAskPermissionPolicyService),

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 noninteractive behavior when Auto Review is disabled

When an SDK host sets nonInteractive: true, uses Ask When Needed mode, and leaves the experimental flag disabled, unconditionally registering this policy changes dangerous Bash calls from the previous yolo-mode-approve result to ask; AgentToolApprovalService then denies them because no approval surface exists. Thus merely upgrading breaks existing headless SDK workflows even though Auto Review defaults off. Keep the old noninteractive policy set unless review is enabled, while still making the detector available for Auto Review's explicit Always Ask reevaluation.

AGENTS.md reference: AGENTS.md:L191-L193

Useful? React with 👍 / 👎.

- Validate the review model and effort once per execute instead of
  re-running the configured-model check and the effort check twice.
- Require the base ask in resolveAutoReview and inline the reason merge.
- Derive the AutoReviewCompleted payload type from its schema.
- Drop the empty-inherited shortcut when merging authorization.

Tests:
- Use a mutating command in the outside-workspace git status test; with
  the read-only `ls` it no longer reached the workspace check.
- Remove table rows and cases that repeat a branch already covered:
  policy-name variants, duplicate tool and mode rows, shared risk
  guidance, thinking rules tested in the core thinking suites, read-only
  shell classification tested by the permission policy suite, and the
  Bash tool copy of the desktop hint delay test.
…ory filtering

Re-review once whenever authorization or the working directory changes
during a review, and fail if it changes again. This replaces the
unchanged/appended/changed classification: a rewritten authorization or
a cwd change now gets one re-review on the latest state instead of
failing outright.

Omit history calls to every tool the default-tool-approve policy
approves, reusing its list instead of a second hand-kept subset. Agent,
Skill, ExitPlanMode, AskUserQuestion, goal, and select_tools calls now
also drop out of the reviewer history; the policy prompt now says calls
that never need approval are omitted.
@7Sageer
7Sageer marked this pull request as draft November 25, 2026 12:48

@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: fd09c5157b

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

gitStatus?: ReviewGitStatus,
): ReturnType<typeof createUserMessage>[] {
const completedIds = new Set(
messages.flatMap((message) => (message.role === 'tool' ? [message.toolCallId] : [])),

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 failed tool calls from review history

Fresh evidence in this commit: the new completedIds set includes every role: 'tool' message without checking isError, so a denied or failed call passes the completion filter and is emitted as an ordinary fact; the reviewer prompt omits tool outputs and describes facts as completed calls. If a failed overwrite is followed by a removal, the reviewer can mistake the failed write for an agent-authored change and allow deleting the original file under the cleanup exception. Require a successful result or include the failure outcome in history.

AGENTS.md reference: AGENTS.md:L211-L213

Useful? React with 👍 / 👎.

}

humanAuthorization(): readonly ReviewText[] {
const own = extractAuthorization(this.loop.history()).filter((entry) => entry.role === '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 Carry compacted boundaries into child reviews

Fresh evidence in this commit: subagent ancestry is persisted from parent.humanAuthorization(), but that method retains only human-instruction entries. When an explicit user prohibition survives compaction only as a compaction_summary (constraint), this filter drops it before a newly created child gets its ancestry snapshot, so that child’s Never Ask review can silently approve a medium-risk action the user explicitly ruled out. Preserve compacted entries as constraints in the child snapshot without treating them as authorization.

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

Useful? React with 👍 / 👎.

Comment on lines +301 to +302
if (input.expanded === true && members.some((member) => reviewHintAt(member.facts, now))) {
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 Replay review state when a tool card is registered

Fresh evidence in this commit: the timeline now records pre-card review state, but expanded mode suppresses the timeline tail here, while setToolAutoReviewing only updates a component that already exists and handleToolCall does not replay the state. When auto_review.started arrives during the permission gate before tool.call.started and the review lasts over 3 seconds, the later card has no Reviewing… hint and the expanded transcript hides the progress. Initialize the new card from the timeline or retain the state until registration.

AGENTS.md reference: AGENTS.md:L114-L114

Useful? React with 👍 / 👎.

@7Sageer
7Sageer marked this pull request as ready for review November 25, 2026 13:57
@7Hanrui

7Hanrui commented Nov 25, 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: 63770aa4f5

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

const keys = Object.keys(status.entries);
if (keys.length === 0) return { cwd: targetCwd, branch: status.branch, clean: true };
const entries = Object.fromEntries(
keys.slice(0, MAX_GIT_STATUS_ENTRIES).map((key) => [key, status.entries[key]!]),

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 Expose truncated Git status to the reviewer

When a repository has more than 50 dirty paths, this silently drops every later entry while still presenting clean: false and entries as the working-tree status. If an omitted path was originally changed by the agent and then modified by the user, the action history can make a pending rm or git restore look like cleanup of the agent's own edit, so Auto Review may approve discarding the user's change. Include relevant action targets regardless of the cap or mark the status as truncated so the reviewer fails closed.

AGENTS.md reference: AGENTS.md:L211-L213

Useful? React with 👍 / 👎.

# Conflicts:
#	packages/kap-server/docs/kap.md
#	packages/kap-server/test/apiSurface.test.ts
@chatgpt-codex-connector

Copy link
Copy Markdown

💡 Codex Review

|| (history !== snapshot.history && !sameAuthorization(snapshot.authorization, this.authorizationOf(history)));

P1 Badge Revalidate destructive reviews against concurrent worktree edits

When a Bash call is reviewed with gitStatus (for example, git restore or rm after an earlier agent edit), a user can edit the same path while the reviewer request is in flight. This check compares only the working directory and prompt authorization, so that edit does not invalidate the review; the stale allow can then let the command discard the user’s change. Revalidate the relevant file state before honoring the allow—a status-only check may miss edits to a path that was already dirty.

AGENTS.md reference: AGENTS.md:L211-L213

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

@7Hanrui

7Hanrui commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 1189e1d1c7

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

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 1189e1d1c7

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

@7Hanrui

7Hanrui commented Nov 25, 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: 1189e1d1c7

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

deadline,
messages: snapshot.messages,
});
context.signal.throwIfAborted();

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 Enforce the review deadline before accepting allow

When the provider completion arrives at or just after the configured deadline but resolves before the timeout callback runs—or when an adapter returns a completed outcome despite the abort—sessionReview.execute() can return allow, and this checks only the parent context.signal, not deadline.signal. The expired result is therefore accepted and can silently execute an action that should have failed closed as a timeout; check the deadline signal before using the outcome.

AGENTS.md reference: AGENTS.md:L211-L213

Useful? React with 👍 / 👎.

@7Sageer
7Sageer merged commit 14affd1 into main Nov 26, 2026
22 checks passed
@7Sageer
7Sageer deleted the auto-review branch November 26, 2026 03:59
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.

4 participants