fix(core): strengthen exit_plan_mode descriptions to prevent empty plan parameter - #5188
Conversation
…an parameter Signed-off-by: Alex <alex.tech.lab@outlook.com>
wenshao
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅ — qwen3.7-max via Qwen Code /review
|
@qwen-code /triage |
|
Thanks for the PR, @Alex-ai-future! Template looks good ✓ On direction: solid alignment. Empty On approach: the scope is tight — two lines of prompt text plus two tests asserting they exist. This is about as minimal as it gets. One thing worth noting: JSON Schema supports Moving on to code review and testing. 🔍 中文说明感谢贡献,@Alex-ai-future! 模板完整 ✓ 方向:对齐。空 方案:范围紧凑——两行提示文本加两个断言测试。这是最精简的改动了。值得注意的一点:JSON Schema 支持 进入代码审查和测试 🔍 — Qwen Code · qwen3.7-max |
Code ReviewClean. The diff is exactly what the PR describes — two additions of the constraint text The tests use a type cast to reach One minor observation (not a blocker): the constraint is enforced at two layers now — prompt text (this PR) and runtime validation ( TestingUnit TestsAll 29 tests pass, including the 2 new constraint-text assertions. Dev Build Sanity CheckThis is a prompt-only change with no TUI impact (the PR correctly marks Evidence as N/A). Ran the dev build to confirm it loads and the tool schema is well-formed: Dev build starts cleanly, tool loads, model responds using the tool definition. No errors or warnings from the schema changes. 中文说明代码审查干净。diff 完全符合 PR 描述——两处添加约束文本 测试使用类型断言来访问 一个小观察(不是阻塞项):约束现在在两层执行——提示文本(本 PR)和运行时校验( 测试单元测试29/29 测试通过,包括 2 个新增的约束文本断言。 开发构建验证纯提示词改动,无 TUI 影响(PR 正确将 Evidence 标记为 N/A)。运行开发构建确认加载正常且工具 schema 格式正确。构建正常启动,工具加载成功,无错误或警告。 — Qwen Code · qwen3.7-max |
Verdict: Approve ✅This is a tight, well-scoped PR that does exactly one thing and does it cleanly. Stepping back: the problem is real (models — especially smaller ones — sometimes call The diff is minimal: two string additions in the right places, two tests protecting them. No logic changes, no scope creep, no drive-by refactors. The tests pass, the dev build runs clean. If I had to maintain this in six months, I'd thank the author for keeping it focused. Shipping it. 🚀 中文说明结论:批准 ✅这是一个紧凑、范围明确的 PR,只做了一件事且做得干净。 退一步看:问题是真实的(模型——尤其是较小的模型——有时会用 diff 最精简:两处正确的字符串添加,两个保护性测试。无逻辑变更,无范围蔓延,无顺手重构。测试通过,开发构建运行正常。 如果六个月后需要维护这个改动,我会感谢作者保持了聚焦。 合并吧 🚀 — Qwen Code · qwen3.7-max |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
Local verification — real tests + BEFORE/AFTER A/BBuilt and ran the real suites locally (tmux + Setup
1. Suites & typecheck
2. The new tests genuinely assert the new text (control-that-should-change)PR's 2 new tests against the base implementation — both red without the change, exactly as expected: 3. A/B — the text reaches the model, enforcement is untouchedConstructed the real (a) Schema reachability
(b) Enforcement (
(rejection message unchanged: What this confirms / what it can't
Optional follow-up (non-blocking)The schema is JSON Schema draft-07, so the constraint could also be made machine-enforceable by adding RecommendationApprove & merge. Correctly wired, premise verified, no behavioral change, tests green. 中文版(点击展开)本地验证 —— 真实测试 + 改动前后 A/B 对比用 tmux + 环境
1. 测试套件与类型检查
2. 新增测试确实在断言新文本(应当变红的对照)把 PR 的 2 个新测试跑在 base 实现 上:没有改动时都为红,符合预期: 3. A/B —— 文本进入模型、强制校验未动构造真实的 (a) Schema 可达性
(b) 强制校验 (
(拒绝消息不变: 这验证了什么 / 验证不了什么
可选后续(非阻塞)该 schema 是 JSON Schema draft-07,因此该约束还可以机器化强制:给 建议通过并合并。 接线正确、前提已验证、无行为变更、测试通过。 Verified locally via tmux + vitest with a base-vs-PR file swap; harness was temporary and not committed. |
What this PR does
Strengthens the tool description and parameter schema for
exit_plan_modeto explicitly state that theplanparameter must contain actual plan content and that empty strings will be rejected. This reduces the likelihood of the model generating emptyplanvalues, avoiding wasted LLM retry turns.Why it's needed
When in plan mode, the model sometimes calls
exit_plan_modewith an empty string for theplanparameter (e.g.,{ "plan": "" }). The tool's parameter validation correctly rejects this, but this wastes a full LLM turn (tokens + latency) and occasionally triggers the retry loop detector after repeated failures.The current parameter description does not explicitly state the non-empty constraint. JSON Schema's
requiredonly ensures the key exists — it does not prevent empty string values. Weaker or smaller models may interpret{ "plan": "" }as satisfying the schema requirement.This is a follow-up to #4853, where Finding 3 noted that weaker models struggle with the plan mode exit path.
Reviewer Test Plan
How to verify
packages/core/src/tools/exitPlanMode.ts.npm run dev, enter plan mode with/plan, and observe whether the model still generates emptyplanparameters.Evidence (Before & After)
N/A — prompt-level change, no TUI impact. The modified text is part of the model-facing tool description, not user-visible UI.
Tested on
Environment (optional)
Local development,
npm run dev.Risk & Scope
planoccurrences. If the prompt optimization proves insufficient, deeper fixes (system prompt reinforcement, error message improvement, or schema validation restoration) may be needed as follow-ups.Linked Issues
Fixes #5177
中文说明
这个 PR 做了什么
强化了
exit_plan_mode的工具描述和参数 schema,明确声明plan参数必须包含实际的计划内容,空字符串将被拒绝。这降低了模型生成空plan值的可能性,避免浪费 LLM 重试轮次。为什么需要
当处于 plan mode 时,模型有时会调用
exit_plan_mode但传入空字符串的plan参数(如{ "plan": "" })。工具的参数校验能正确拒绝这种情况,但这浪费了一个完整的 LLM 回合(token + 延迟),最坏情况下会在重复失败后触发重试循环检测器。当前的参数描述没有显式声明非空约束。JSON Schema 的
required仅确保键存在——不阻止空字符串值。较弱或较小的模型可能认为{ "plan": "" }满足了 schema 要求。这是 #4853 的后续工作,该 PR 的发现 3 指出较弱的模型在 plan mode 退出路径上存在困难。
审查者测试计划
如何验证
packages/core/src/tools/exitPlanMode.ts中的工具描述和参数 schema 是否包含非空约束文本。npm run dev,使用/plan进入 plan mode,观察模型是否仍生成空plan参数。证据(修改前后)
N/A — 纯提示词修改,无 TUI 影响。修改的文本是模型面向的工具描述的一部分,非用户可见 UI。
测试平台
环境(可选)
本地开发环境,
npm run dev。风险与范围
plan出现次数的减少。如果提示词优化效果不理想,可能需要后续进行更深层的修复(系统提示词强化、错误消息优化或 schema 校验恢复)。关联 Issue
修复 #5177