Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 5993cc2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
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 |
|
@codex review |
There was a problem hiding this comment.
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.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 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".
| const thinkingEffort = modelAlias === resolved.modelAlias | ||
| ? resolved.thinkingLevel | ||
| : resolveThinkingEffortForModel( | ||
| undefined, | ||
| this.config.get<ThinkingConfig>(THINKING_SECTION), |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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 👍 / 👎.
| const authorization = retained.flatMap((message) => { | ||
| if (authorizationChars >= MAX_AUTHORIZATION_TOTAL_CHARS) return []; |
There was a problem hiding this comment.
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 👍 / 👎.
| const text = boundedText(part.text, remaining); | ||
| remaining -= text.length; |
There was a problem hiding this comment.
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'], |
There was a problem hiding this comment.
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 👍 / 👎.
| const content = boundedContent(message.content, MAX_AUTHORIZATION_ENTRY_CHARS); | ||
| return [{ role, content }]; |
There was a problem hiding this comment.
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 👍 / 👎.
| const agentsMd = this.instructions.agentsMd; | ||
| const cwd = this.workspace.workDir; |
There was a problem hiding this comment.
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 👍 / 👎.
| return { | ||
| kind: 'ask', | ||
| reason: { review_risk: decision.risk }, |
There was a problem hiding this comment.
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 👍 / 👎.
| 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); |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 👍 / 👎.
| 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); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| if (message.origin?.kind === 'user' || message.origin?.kind === 'plugin_command') { | ||
| return 'human-instruction'; |
There was a problem hiding this comment.
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 👍 / 👎.
| 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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
commit: |
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.
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 ?? '', |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| {"risk":"low","decision":"allow"} | ||
| {"risk":"medium","decision":"allow"} | ||
| {"risk":"medium","decision":"deny","reason":"..."} | ||
| {"risk":"high","decision":"deny","reason":"..."} |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
|
@codex review |
There was a problem hiding this comment.
💡 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, |
There was a problem hiding this comment.
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 👍 / 👎.
| description: tool?.description ?? '', | ||
| parameters: tool?.parameters ?? {}, |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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 👍 / 👎.
| if (message.role === 'tool') { | ||
| if (message.toolCallId === pendingCallId) return []; | ||
| return [{ | ||
| kind: 'tool-result', | ||
| role: 'fact', | ||
| toolCallId: message.toolCallId, | ||
| isError: message.isError === true, | ||
| }]; |
There was a problem hiding this comment.
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 👍 / 👎.
…view on non-managed main models
There was a problem hiding this comment.
💡 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) => { |
There was a problem hiding this comment.
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
|
@codex review |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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; |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 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".
| 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. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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 👍 / 👎.
| if (origin.kind === 'user' || origin.kind === 'plugin_command') return 'human-instruction'; | ||
| if (origin.kind === 'skill_activation' && origin.trigger === 'user-slash') return 'human-instruction'; |
There was a problem hiding this comment.
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
|
@codex review |
There was a problem hiding this comment.
💡 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".
| pending_action: sectionJson({ | ||
| name: context.toolCall.name, | ||
| arguments: context.args, |
There was a problem hiding this comment.
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 👍 / 👎.
| 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' }, |
There was a problem hiding this comment.
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 👍 / 👎.
| 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; |
There was a problem hiding this comment.
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 👍 / 👎.
| abandon({ isError: true, output: 'Aborted before command started' }); | ||
| }; | ||
| return { | ||
| accesses: readOnly?.paths.map((path) => ({ kind: 'file', operation: 'read', path })), |
There was a problem hiding this comment.
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 👍 / 👎.
There was a problem hiding this comment.
💡 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); |
There was a problem hiding this comment.
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 👍 / 👎.
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["不执行,返回工具错误"]底层结果来自同一次遍历里模式级放行之后的下一条策略,所以"哪些调用需要审"只有一个真相来源,不需要再维护工具豁免名单,也不再重跑策略链。权限门留在
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。关键决策
AutoReviewFeature经IAgentPermissionGate.registerReviewer挂载复核门控与策略评估选项AgentPermissionGate和AgentPermissionPolicyService直接依赖features/autoReviewsrc/features/autoReview指向src/agent/核心层,关闭实验或单测核心权限服务时无耦合AutoReviewService内使用IProtocolAdapterRegistry的独立核心请求器,沿用resolveCompletionBudget与isRetryableGenerateErrorIAgentLoopService.requester或单独IModelRequester服务actionrm -f/--force及sudo前缀都标recursive delete/sudorm带递归标志时标recursive delete;纯强制删除标force delete;不再单独标sudowaitUntil阶段等待决策与审批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
全屏折叠,复核等待中。标题保持工作摘要,状态在尾部:
全屏展开,同一句话只出现在卡片里:
复核拒绝后的审批弹窗。理由在命令上方,不使用
Dangerous:的 error 加粗:此前真实交互验证中,reviewer 放行后提示消失并恢复工具结果:
复核请求的细节
[auto_review] model优先;未配置时使用[secondary_model]默认模型,再回退到主模型。waitUntil阶段等待,每次 legacy starting 决议结束时取消该调用尚未完成的复核。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重试。approved: true)、待审工具名称与完整参数,以及目标执行目录的 Git 工作树状态gitStatus(branch、clean、未提交/未跟踪文件entries)。用户指令、AGENTS.md 中明确授权的项目工作流和用户已批准的调用作为授权依据;父级 subagent 指令仅在已授权范围内细化委派;未获人工批准的历史工具调用仅作为事实参考。不按条数或字符裁剪,保持稳定缓存前缀;不发送工具输出、tool-result、媒体与面向主 Agent 的工具description/parameters元数据。请求超出模型窗口时,这次复核失败,不重试,并触发一次自动上下文压缩。Behavior Changes and Affected Users
false;可静态证明只读的 Bash 按下方独立规则直接放行ask/deny规则cat、ls等只读调用仍需人工确认;开启 Auto Review 时仍会送审underlying为 approve,不送 Auto Review;此行为不依赖实验 flagask/deny规则;敏感文件与.git规则仍优先生效/dev/null)、命令 / 进程替换、变量赋值、后台执行、here-string、解析失败或未覆盖的命令(包括find、jq、git)不静态放行allow规则仍可放行;需要逐次确认时配置ask/denyallow执行;deny或失败转人工审批;print 模式无人审批时带复核理由拒绝KIMI_CODE_EXPERIMENTAL_AUTO_REVIEW=1、[experimental] auto_review = true或总实验开关的 yolo 用户allow执行;deny或失败不执行并返回工具错误,主 Agent 可继续allow规则可跳过复核allow规则、本会话已批准、显式 denyrm -rf、shutdown等)allow和本会话批准不生效allow和本会话批准直接执行,其余落到模式放行,底层结果为ask时送复核allow规则覆盖的危险命令allow规则命中后不复核{risk, decision, reason}契约approved: true)可定义授权范围;直接父 Agent 指令只能在已授权范围内细化委派(非 fork 子 Agent 自动继承主 Agent 的人类授权指令)[secondary_model]默认模型,未配置时回退主模型;向所选模型所属 provider 发送上方"复核请求的细节"所列内容,并使用所选模型自身的输出预算与能力;用量计入会话[secondary_model]的用户)[auto_review] model显式指定模型(如设为主模型别名);关闭实验 flagxhigh会占满默认 30 秒截止,复核超时后转人工审批[auto_review] timeout_ms仍可加长截止时间[auto_review] timeout_ms可缩短等待waitUntil阶段等待。每次 legacy starting 决议结束时取消该调用尚未完成的复核,沿用main的并发 handler 语义anyOf,OpenAI strict Structured Outputs 会拒绝;本地验收拒绝allow带理由和high+allowallow上附理由的用户[auto_review]、auto_review_decision与auto_review.decisionmodel、timeout_ms;遥测含决策、风险、耗时、触发策略名与模型别名;wire 另持久化 deny reason / failed reason,不保存整段 promptKIMI_DISABLE_TELEMETRY语义不变ApprovalRequest.approvalDetail经node-sdk/klient传给 TUI 与 SDK 调用方,并经 kap-server 的approval_detail透传给 desktop/web。TUI 在原操作上方用 warning 显示标题,理由 dim 且最多两行;desktop/web 在现有审批卡片中展示同一理由。VS Code、ACP 保持原审批卡片Reviewing…,决策到达或 turn 取消后消失;desktop/web 通过auto_review阶段在活动摘要和工具行显示复核状态。print、ACP、SDK 不显示Running commands,展开视图也不读取卡片正文中的复核提示Reviewing <subject>;展开不重复尾部,只在卡片里显示Reviewing…。决策或取消后清除resolveCompletionBudget,不恢复已删除的旧请求兼容层tool-call参数原样送出(裁剪tool-result与toolMetadata,在用户人工批准过的tool-call上附带approved: true,并在<pending_action>中附带目标目录gitStatus)。请求超出模型窗口时这次复核失败,不重试,并触发一次自动压缩测试覆盖:
permissionGate.test.ts:yolo 下静态 ask 先送 reviewer;模式级放行且underlying为 ask 时送审;用户 allow、session 授权、静态 deny 不送审;其他 listener veto 或 final allow 时不复核;静态否决后不再运行后续permittinghook;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):apps/desktop/src/renderer是 desktop / Web 的统一 renderer,不再有独立apps/web源码。completion-budget.ts辅助函数同步移除,主循环未改。agent-core-v2typecheck、desktoppnpm --filter kimi-code-app run typecheck通过。pnpm lint全部通过:注释检查、oxlint 0 errors / 0 warnings、导入边界、guards、ratchet 与说明文件检查。scripts/release.test.mjs含 10 处从原 code-app 仓库搬入的node:test写法,ratchet 按迁移代码规则经--update --allow-increase登记计数;toolExecutor.test.ts已消除的一项同步下调。没有修改发布逻辑,CI 所需的最新 main 已合入。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-v2typecheck 与 build 通过;permissionGate.test.ts25 个测试通过。permissionPolicyService.test.ts148 个测试、autoReview.test.ts37 个测试、Bash 58 个测试通过。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 未修改这些恢复、锁与进程管理实现。store.test.ts228 个测试在 PR 与纯main上均通过;remoteprocess.test.ts23 个测试单独通过。完整 engine 回归没有一轮全绿,以上基线复现与剩余并发波动需要单独处理。pnpm lint(type-aware)通过:0 errors,2768 warnings。完整仓库pnpm run typecheck也已通过,覆盖 engine、kap-server、SDK、CLI、VS Code 与可视化应用。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-serverconversation 39 个测试、SDK session-event types 9 个测试通过;两端 typecheck 通过。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。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.