Version: 0.9.9.dev.260408

后端:
1. 粗排后分流与顺序守卫落地,支持“无明确微调偏好时粗排后直接收口”,并新增 allow_reorder / needs_refine_after_rough_build 语义,打通 chat→rough_build→execute/order_guard→deliver 路由。
2. execute 工具执行链路修复:清理乱码坏块与重复分支;新增 min_context_switch 未授权拦截;补齐 suggested 顺序基线初始化与顺序守卫联动。
3. 新增复合写工具 min_context_switch(减少上下文切换)并接入注册、参数解析、写工具白名单、提示词与文档;仅在用户明确允许打乱顺序时可用。
4. 工具口径升级:find_first_free 支持 day/day_start/day_end 范围参数并统一文案;移除 find_free 兼容别名;读写工具输出统一到“第N天(星期X)”格式。
5. prompt 同步升级:chat/execute/execute_context 增加粗排后是否继续微调、顺序授权、min_context_switch 使用边界与返回示例约束。
6. handoff 文档重命名并重写下班交接重点:下一步聚焦“工具收敛能力研究 + 运行态必要参数重置(不丢运行态)”。
7. 同步更新调试日志文件。
前端:无
仓库:无
This commit is contained in:
Losita
2026-04-08 23:55:09 +08:00
parent 4195e65cba
commit 21b864390b
21 changed files with 3546 additions and 1009 deletions

View File

@@ -34,7 +34,9 @@ type roughBuildApplyStats struct {
// 4. 调用 RoughBuildFunc 拿到粗排结果([]RoughBuildPlacement
// 5. 把粗排结果写入 ScheduleState把已落位任务标记为 suggested
// 6. 若粗排后仍存在真实 pending则写入正式 abort 结果并结束本轮;
// 7. 否则推送"粗排完成"状态,清除 NeedsRoughBuild 标记,进入执行阶段。
// 7. 否则按“是否需要粗排后立即微调”分流:
// - 无明确微调诉求:直接 Done -> Deliver
// - 有明确微调诉求:进入 Execute。
func RunRoughBuildNode(ctx context.Context, st *newagentmodel.AgentGraphState) error {
if st == nil {
return fmt.Errorf("rough build node: state is nil")
@@ -63,6 +65,7 @@ func RunRoughBuildNode(ctx context.Context, st *newagentmodel.AgentGraphState) e
// 没有任务类 ID 时静默跳过粗排,直接进入执行阶段。
flowState.Phase = newagentmodel.PhaseExecuting
flowState.NeedsRoughBuild = false
flowState.NeedsRefineAfterRoughBuild = false
return nil
}
@@ -133,16 +136,29 @@ func RunRoughBuildNode(ctx context.Context, st *newagentmodel.AgentGraphState) e
return nil
}
// 8. 推送完成状态
// 8. 计算是否需要“粗排后立即微调”
//
// 1. 只在“无计划直执行”链路下应用该止血分流;
// 2. 有计划链路依旧进入 execute避免改变既有 plan->execute 语义;
// 3. chat 路由明确标记 needs_refine_after_rough_build=true 时才进微调。
shouldRefineAfterRoughBuild := flowState.HasPlan() || flowState.NeedsRefineAfterRoughBuild
// 9. 推送完成状态(区分“继续微调”与“直接收口”两种路径)。
doneStatus := "rough_build_done"
doneMessage := fmt.Sprintf("初始排课方案已生成,共 %d 个任务已预排,进入微调阶段。", len(placements))
if !shouldRefineAfterRoughBuild {
doneStatus = "rough_build_done_no_refine"
doneMessage = fmt.Sprintf("初始排课方案已生成,共 %d 个任务已预排。本轮按默认策略先结束;如需优化,请继续告诉我你的偏好。", len(placements))
}
_ = emitter.EmitStatus(
roughBuildStatusBlock,
roughBuildStageName,
"rough_build_done",
fmt.Sprintf("初始排课方案已生成,共 %d 个任务已预排,进入微调阶段。", len(placements)),
doneStatus,
doneMessage,
false,
)
// 9. 把粗排完成信息写入 pinned context Execute 阶段的 LLM 直接进入查看和微调
// 10. 把粗排完成信息写入 pinned context后续节点能拿到一致事实
// 构造任务类 ID 字符串,供 pinned block 明确标注,避免 Execute LLM 因找不到 task_class_id 来源而 ask_user。
idParts := make([]string, len(taskClassIDs))
@@ -154,18 +170,31 @@ func RunRoughBuildNode(ctx context.Context, st *newagentmodel.AgentGraphState) e
pinnedContent := fmt.Sprintf(
"后端已自动运行粗排算法(任务类 ID[%s]),初始排课方案已写入日程状态(共 %d 个任务已预排)。\n"+
"这些预排任务已标记为 suggested表示“可继续优化的建议落位”不是待补排任务。\n"+
"请先调用 get_overview 查看整体分布,再使用 move / swap / unplace 微调不合理的位置。\n"+
"本轮不需要再调用 place也无需再次触发粗排。",
idStr, len(placements),
)
if shouldRefineAfterRoughBuild {
pinnedContent += "\n请先调用 get_overview 查看整体分布,再使用 move / swap / unplace 微调不合理的位置。"
} else {
pinnedContent += "\n当前未收到明确微调偏好流程将先收口如需进一步优化请基于本次结果提出调整要求。"
}
st.EnsureConversationContext().UpsertPinnedBlock(newagentmodel.ContextBlock{
Key: "rough_build_done",
Title: "粗排已完成",
Content: pinnedContent,
})
// 10. 清除标记,进入执行阶段
// 11. 清除粗排标记,并按分流结果进入执行或直接收口
//
// 1. 无明确微调诉求:直接标记 completedgraph 会路由到 deliver
// 2. 有明确微调诉求:进入 execute 节点继续工具微调;
// 3. 无论哪条路径,都要重置粗排相关标记,避免污染后续轮次。
flowState.NeedsRoughBuild = false
flowState.NeedsRefineAfterRoughBuild = false
if !shouldRefineAfterRoughBuild {
flowState.Done()
return nil
}
flowState.Phase = newagentmodel.PhaseExecuting
return nil
}