Version: 0.9.11.dev.260409
后端: 1. conv 并行迁移与切流接线(旧目录下沉到 newAgent/conv) - 新建 newAgent/conv/schedule_provider.go、schedule_state.go、schedule_preview.go、schedule_persist.go,保持原有排程转换/预览/持久化能力; - 删除旧目录 conv/schedule_provider.go、schedule_state.go、schedule_preview.go、schedule_persist.go; - 更新 cmd/start.go 与 service/agentsvc/agent_newagent.go,ScheduleProvider/SchedulePersistor 与 preview 转换统一切到 newAgent/conv; - 删除旧 conv/schedule_state_test.go(迁移期测试文件清理)。 2. execute 循环上下文收口增强(历史归档 + 当前轮清晰化) - 更新 node/chat.go:仅在 completed 收口时写 execute_loop_closed marker,供后续 prompt 分层归档; - 更新 prompt/execute_context.go:msg1/msg2 升级为 V3,按收口标记拆分“历史归档 loop / 当前活跃 loop”,并增加 msg1 长度预算裁剪; - 更新 node/execute.go:新增 execute 置顶上下文同步(execution_context/current_step),在轮次开始与 next_plan 后即时刷新; - 更新 prompt/execute.go + execute_context.go:补齐“当前计划步骤 + done_when”强约束,禁止未达成判定时提前 next_plan。 3. 图路由与执行策略微调 - 更新 graph/common_graph.go:Plan/Confirm 分支允许直接进入 Deliver 收口; - 更新 node/plan.go:always_execute 链路下补发计划摘要并写入历史,保证自动执行与手动确认文案一致; - 更新 model/common_state.go:DefaultMaxRounds 从 30 提升到 60。 4. 复合工具规划器重构(去重实现,复用 logic 公共能力) - 更新 tools/compound_tools.go:min_context_switch / spread_even 改为调用 backend/logic 规划器(PlanMinContextSwitchMoves / PlanEvenSpreadMoves); - 新增 state_id↔logic_id 映射层,统一入参与回填,避免工具层与规划层 ID 语义耦合; - 删除 compound_tools 内部重复的规划/归一化/分组/打分实现,减少第三份复制逻辑。 5. 同步调试与文档 - 更新 newAgent/Log.txt 调试日志; - 新增 memory/记忆模块实施计划.md(面试优先版到产品可用版的落地路线)。 前端:无 仓库:无
This commit is contained in:
@@ -320,7 +320,7 @@ func BuildExecuteMessages(state *newagentmodel.CommonState, ctx *newagentmodel.C
|
||||
BuildExecuteSystemPrompt(),
|
||||
state,
|
||||
ctx,
|
||||
buildExecuteStrictJSONUserPrompt(),
|
||||
buildExecuteStrictJSONUserPromptWithPlan(state),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -332,6 +332,50 @@ func BuildExecuteMessages(state *newagentmodel.CommonState, ctx *newagentmodel.C
|
||||
)
|
||||
}
|
||||
|
||||
// buildExecuteStrictJSONUserPromptWithPlan 在通用 JSON 约束上补充“当前计划步骤”强约束。
|
||||
//
|
||||
// 职责边界:
|
||||
// 1. 负责把“当前是第几步、当前步骤内容、done_when 判定”明确写进用户指令;
|
||||
// 2. 不负责替代系统提示词中的工具规则和安全边界;
|
||||
// 3. 当 state 无法提供有效当前步骤时,仅追加兜底提示,不在此处推进流程状态。
|
||||
func buildExecuteStrictJSONUserPromptWithPlan(state *newagentmodel.CommonState) string {
|
||||
base := buildExecuteStrictJSONUserPrompt()
|
||||
if state == nil || !state.HasPlan() {
|
||||
return base
|
||||
}
|
||||
|
||||
current, total := state.PlanProgress()
|
||||
step, ok := state.CurrentPlanStep()
|
||||
if !ok {
|
||||
return strings.TrimSpace(base + `
|
||||
|
||||
计划步骤强约束:
|
||||
- 当前没有可执行的计划步骤,请先基于已有事实检查是否已完成全部计划。
|
||||
- 若全部计划已完成:输出 action=done,并在 goal_check 总结完成证据。
|
||||
- 若未完成但缺少关键信息:输出 action=ask_user。`)
|
||||
}
|
||||
|
||||
stepContent := strings.TrimSpace(step.Content)
|
||||
if stepContent == "" {
|
||||
stepContent = "(当前步骤内容为空,以 done_when 为准)"
|
||||
}
|
||||
doneWhen := strings.TrimSpace(step.DoneWhen)
|
||||
if doneWhen == "" {
|
||||
doneWhen = "(未提供 done_when,需基于当前步骤目标给出可验证完成证据)"
|
||||
}
|
||||
|
||||
return strings.TrimSpace(fmt.Sprintf(`%s
|
||||
|
||||
计划步骤强约束:
|
||||
- 你当前只允许推进第 %d/%d 步。
|
||||
- 当前步骤内容:%s
|
||||
- 当前步骤完成判定(done_when):%s
|
||||
- 未满足 done_when 时:只能输出 continue / confirm / ask_user,禁止输出 next_plan。
|
||||
- 满足 done_when 时:优先输出 action=next_plan,并在 goal_check 逐条对照 done_when 给出证据。
|
||||
- 禁止跳步:不要提前执行后续步骤。`,
|
||||
base, current, total, stepContent, doneWhen))
|
||||
}
|
||||
|
||||
// buildExecutePromptWithFormatGuard 统一补一层更硬的 JSON 输出约束。
|
||||
func buildExecutePromptWithFormatGuard(base string) string {
|
||||
base = strings.TrimSpace(base)
|
||||
|
||||
Reference in New Issue
Block a user