Repository navigation
Conversation
🦋 Changeset detectedLatest commit: 6a266c6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requirement or Bug
在 #4655 的实验性 Auto Review 基础上,让每次工具调用复核由一个临时的只读 subagent 完成。
Write和Edit跳过复核,其余符合送审条件的工具调用沿用原有审批与拒绝流程。Stacked on #4655;本 PR 的 base 是
auto-review,diff 只包含这项后续改动。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
核心思路:复用现有 Agent 生命周期和只读
exploreprofile 承载 reviewer。每次尝试创建独立 subagent,继承调用方的环境与目录,提交复核 prompt,读取最终回复中的 JSON 决定,随后移除该 subagent。主 Agent 的授权上下文、风险判定和allow/deny/ failure 分流保持在 Auto Review 服务中。sequenceDiagram participant Main as Main agent participant Review as Auto Review participant Reviewer as Temporary read-only subagent Main->>Review: Qualifying tool call Review->>Reviewer: Create with inherited environment and cwd Review->>Reviewer: Review policy and existing review context Reviewer-->>Review: JSON decision in final response Review->>Review: Validate decision and authorization snapshot Review->>Reviewer: Remove Review-->>Main: Apply existing permission outcomepackages/agent-core-v2/src/features/autoReview/autoReviewGate.ts:在送审入口排除Write/Edit;其余触发条件和审批分流不变。packages/agent-core-v2/src/features/autoReview/reviewService.ts:用 Agent 生命周期替换直接协议请求;保留模型选择、授权与 Git 状态输入、30 秒默认截止、最多 3 次尝试、4 路并发、取消、事件和用量记录。packages/agent-core-v2/src/session/agentLifecycle/agentLifecycleService.ts:广播权限模式时识别 reviewer 标签,保持 reviewer 的manual模式。runAgentTurn和 Agent 生命周期,覆盖 reviewer 创建、运行、清理、重试与权限模式隔离。auto_review配置说明同步更新送审范围和只读 subagent 行为。旧请求路径的功能去向
[auto_review] model、[secondary_model]、主模型回退buildReviewMessages,与复核策略一起组成 subagent promptDecisionSchemaauto_review.started/auto_review.decision、遥测explore的只读工具集与manual权限;最终 JSON 校验保留Behavior Changes and Affected Users
Write/Edit的送审ask/deny权限规则explore只读 subagent,继承当前环境与 cwd,结束后移除auto/yolomanual[auto_review] model可选择其他模型auto_review缓存键[auto_review] model可显式选择模型;关闭实验 flagWrite/Edit跳过、只读 subagent 和 profile 驱动的模型行为受影响模块与测试覆盖:
autoReviewGate:Write/Edit跳过,Bash仍触发复核。reviewService:默认及显式模型、explore绑定、manual模式、运行后清理、授权与 Git 上下文、非法输出与限流重试、上下文溢出、超时、并发、取消、事件、用量和遥测。AgentLifecycleService:广播yolo后主 Agent 切换、reviewer 保持manual。docs/en/configuration/config-files.md与docs/zh/configuration/config-files.md:双语结构一致,文档构建通过。Validation
pnpm exec tsc -p packages/agent-core-v2/tsconfig.json --noEmit:通过。pnpm exec vitest run --reporter=agent packages/agent-core-v2/test/features/autoReview/autoReview.test.ts packages/agent-core-v2/test/session/agentLifecycle/agentLifecycle.test.ts:2 个测试文件、84 项测试通过。pnpm lint:0 errors / 0 warnings,导入边界、guards、ratchet 与说明文件检查通过。pnpm --dir docs run build:通过;保留构建工具已有的 ES2024 target 和 chunk size 警告。runAgentTurn测试替身。Checklist
/approve). 关联父 PR feat(agent-core-v2): add experimental auto review and read-only Bash approvals #4655;本 PR 为同仓库 stacked Draft。gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update. 已更新双语配置文档;base 分支没有该技能引用的docs/scripts/sync-changelog.mjs,未改动发布变更记录。