feat(plan): 接通 plan-critic 真实 subagent runner - #20
Open
1-ztc wants to merge 2 commits into
Open
Conversation
…E flag Pre-execute subagent critique gated by MOSS_PLAN_VALIDATE (default off) + MOSS_PLAN_VALIDATE_MIN_STEPS (default 5). Critique injected at plan action=approve; issues block approve and flow back to the model. Fail-open on any critic fault. Retention to be decided from A/B benchmark data. Co-Authored-By: Claude <noreply@anthropic.com>
Replace the throwing placeholder in makeSubagentRunner with a real ctx.spawnSubagent call (plan scope, maxTurns=2), the same path create_subagent uses. The critic's system prompt is injected via a new systemPromptOverride parameter threaded through spawnSubagent signature -> SubAgentConfig -> createSubAgentRunner, where it replaces the parent's system prompt for the child run (childSystemPromptParts undefined so prefix-cache doesn't split the override block). Critic is still default-off (MOSS_PLAN_VALIDATE) and fail-open — wiring makes it runnable, not enabled. Real-model A/B to decide retention later. Verified: build + typecheck clean; 9 specs pass (incl. subagent-completion-gate regression after signature change); end-to-end with real provider (MOSS_PLAN_VALIDATE=on) runs without crash/hang. Co-Authored-By: Claude <noreply@anthropic.com>
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.
做了什么
把 plan-critic 的
makeSubagentRunner从 throwing placeholder 换成真实ctx.spawnSubagent调用——critic 终于能真跑(default 仍 off)。这是把"规划质量校验"从空壳框架变成可执行实验的临门一脚。背景
critic 之前(
feature/plan-completion-gate上的3859849)是 default-off + fail-open 的框架,但 runner 是 throw 空壳——当时判断"createSubAgentRunner是 host-deps 工厂,没法从工具调"。探查后发现这判断不成立:moss 已有ctx.spawnSubagent(ToolContext,create_subagent工具在用),critic 该走同一条路。唯一缺口:spawnSubagent签名没有 systemPrompt 参数,critic 要传自己的 critique prompt。改动(沿 spawnSubagent → createSubAgentRunner 链路加 systemPromptOverride)
tool-types.ts—spawnSubagent签名加systemPromptOverride?: stringsubagent-orchestrator.ts—SubAgentConfig加systemPromptOverride?: stringmoss-agent.ts—spawnSubagent闭包透传params.systemPromptOverride进 runner configsubagent-runner.ts—createSubAgentRunner用config.systemPromptOverride覆盖子 agent systemPrompt(override 时childSystemPromptParts设 undefined,不破坏 prefix-cache 切分)plan-tools.ts—makeSubagentRunner接真实ctx.spawnSubagent:scope: "plan"(read-only)、maxTurns: 2(critic 一轮出 JSON,2 轮覆盖偶发截断,不让它漂移成执行)、systemPromptOverride: critic promptcherry-pick 自
3859849:plan-critic.ts/plan-critic-prompt.ts/19-plan-mode.md/plan-critic.spec.mjs(无冲突,从 main 干净开)。设计决定
MOSS_PLAN_VALIDATE默认关,主线零影响;fail-open 保证任何 critic 故障不阻塞 approve。测试
9 个 spec 全过(含关键回归:
subagent-completion-gate真起createSubAgentRunner,改签名后没坏)。build + typecheck 干净。端到端:MOSS_PLAN_VALIDATE=on+ 真实 provider(DeepSeek)跑 6 步 plan 任务,is_error:false不崩不挂。已知限制
criticModel字段,首轮同模型测"critic 这层本身有没有用";换更强模型留后续。plan-critic-integ.spec.mjs是接线 smoke(off baseline + on 不崩),issues 阻止 approve 路径靠 mock provider 测不出(单元runPlanCritique已覆盖)。🤖 Generated with Claude Code