Feat: tRPC-Agent对齐Claude Code Plan Mod能力 - #319
Conversation
Feature: - 参考claude code 的工具设计、提示词设计进行框架plan mod能力的设计与实现。 - 支持模型主动进入plan 模式 & 用户主动选择plan模式。 - 支持agui 解析 toolset能力 BugFix: - 修复agui协议传递state数据无法有效更新问题。 Doc: - 支持plan mod指引文档。 - 单独列出todowrite、task、goal的指引文档。
AI Code Review审查结论不通过 审查范围:本次提交 发现的问题严重
问题: 触发条件: 在 AG-UI Plan Mode 流程中计划经 实际影响: 已批准计划被新 修正方向: 在 |
| existing = self._load_plan(ctx) | ||
| if existing is not None and existing.is_gate_active(): | ||
| return | ||
| record, error = apply_enter( | ||
| existing, | ||
| objective=self._objective_from_context(ctx), | ||
| now_unix=int(time.time()), | ||
| ) | ||
| if error: | ||
| logger.warning("auto-enter plan mode could not create plan: %s", error) | ||
| return | ||
| self._save_plan(ctx, record) |
There was a problem hiding this comment.
问题: _ensure_forced_plan 仅在已存在计划且 is_gate_active() 或状态为 PENDING_ENTER 时跳过自动进入;当已存在计划的状态为 APPROVED(gate 未激活)时,_should_force_enter 仍为真(会话 state 中 agent_mode 仍为 plan),apply_enter 因此创建一个全新的 EXPLORING 计划并覆盖既有已批准计划,重新激活写工具门禁。
触发条件: 在 AG-UI Plan Mode 流程中计划经 exit_plan_mode 获批进入 APPROVED 后,会话 state 的 agent_mode 未被任何代码清除(示例 buildRunState() 始终发送 agent_mode=plan);用户随后发送一条普通实现指令(非 HITL 恢复),触发 before_model 中的 _ensure_forced_plan。
实际影响: 已批准计划被新 EXPLORING 计划覆盖,写工具(Write/Edit/Bash/task_create 等)再次被 before_tool 门禁拦截,导致计划通过审批后无法进入实现阶段——核心功能在 SDK 自带示例的默认流程下即可复现。
修正方向: 在 _ensure_forced_plan(或 apply_enter)中增加终态判断:当 existing.status == PlanStatus.APPROVED 时跳过自动进入(或要求先清理/归档旧计划);或在审批通过时由 apply_approval_decision 清除 force_enter_plan_state_key 指定的会话信号,使自动进入不再重复触发。
Feature:
BugFix:
Doc: