Version: 0.7.1.dev.260321
feat(agent): ✨ 重构智能排程分流与双通道交付,补齐周级预算并接入连续微调复用 - 🔀 通用路由升级为 action 分流(chat/quick_note_create/task_query/schedule_plan),路由失败直接返回内部错误,不再回落聊天 - 🧭 智能排程链路重构:统一图编排与节点职责,完善日级/周级调优协作与提示词约束 - 📊 周级预算改为“有效周保底 + 负载加权分配”,避免有效周零预算并提升资源利用率 - ⚙️ 日级并发优化细化:按天拆分 DayGroup 并发执行,低收益天(suggested<=2)跳过,单天失败仅回退该天结果并继续全局 - 🧵 周级并发优化细化:按周并发 worker 执行,单周“单步动作”循环(每轮仅 1 个 Move/Swap 或 done),失败周保留原方案不影响其它周 - 🛰️ 新增排程预览双通道:聊天主链路输出终审文本,结构化 candidate_plans 通过 /api/v1/agent/schedule-preview 拉取 - 🗃️ 增补 Redis 预览缓存读写与清理逻辑,新增对应 API、路由、模型与错误码支持 - ♻️ 接入连续对话微调复用:命中同会话历史预览时复用上轮 HybridEntries,避免每轮重跑粗排 - 🛡️ 增加复用保护:仅当本轮与上轮 task_class_ids 集合一致才复用;不一致回退全量粗排 - 🧰 扩展预览缓存字段(task_class_ids/hybrid_entries/allocated_items),支撑微调承接链路 - 🗺️ 更新 README 5.4 Mermaid(总分流图 + 智能排程流转图)并补充决策文档 - ⚠️ 新增“连续微调复用”链路我尚未完成测试,且文档状态目前较为混乱,待连续对话微调功能真正测试完成后再统一更新
This commit is contained in:
@@ -7,12 +7,12 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
)
|
||||
|
||||
// schedulePlanRunner 是"单次图运行"的请求级依赖容器。
|
||||
// schedulePlanRunner 是“单次图执行”的请求级依赖容器。
|
||||
//
|
||||
// 设计目标:
|
||||
// 1) 把节点运行所需依赖(model/deps/emit/extra/history)就近收口;
|
||||
// 2) 让 graph.go 只保留"节点连线"和"方法引用",提升可读性;
|
||||
// 3) 避免在 graph.go 里重复出现内联闭包和参数透传。
|
||||
// 1. 把节点运行所需依赖(model/deps/emit/extra/history)就近收口;
|
||||
// 2. 让 graph.go 只保留“节点连线与分支决策”,提升可读性;
|
||||
// 3. 避免在 graph.go 里重复出现大量闭包和参数透传。
|
||||
type schedulePlanRunner struct {
|
||||
chatModel *ark.ChatModel
|
||||
deps SchedulePlanToolDeps
|
||||
@@ -20,13 +20,15 @@ type schedulePlanRunner struct {
|
||||
userMessage string
|
||||
extra map[string]any
|
||||
chatHistory []*schema.Message
|
||||
// ── ReAct 精排所需 ──
|
||||
outChan chan<- string // SSE 流式输出通道,用于推送 reasoning_content
|
||||
modelName string // 模型名称,用于构造 OpenAI 兼容 chunk
|
||||
|
||||
// weekly refine 需要的上下文
|
||||
outChan chan<- string
|
||||
modelName string
|
||||
|
||||
// daily refine 并发度
|
||||
dailyRefineConcurrency int
|
||||
}
|
||||
|
||||
// newSchedulePlanRunner 构造请求级 runner。
|
||||
// 生命周期仅限一次 graph invoke,不做跨请求复用。
|
||||
func newSchedulePlanRunner(
|
||||
chatModel *ark.ChatModel,
|
||||
deps SchedulePlanToolDeps,
|
||||
@@ -36,37 +38,49 @@ func newSchedulePlanRunner(
|
||||
chatHistory []*schema.Message,
|
||||
outChan chan<- string,
|
||||
modelName string,
|
||||
dailyRefineConcurrency int,
|
||||
) *schedulePlanRunner {
|
||||
return &schedulePlanRunner{
|
||||
chatModel: chatModel,
|
||||
deps: deps,
|
||||
emitStage: emitStage,
|
||||
userMessage: userMessage,
|
||||
extra: extra,
|
||||
chatHistory: chatHistory,
|
||||
outChan: outChan,
|
||||
modelName: modelName,
|
||||
chatModel: chatModel,
|
||||
deps: deps,
|
||||
emitStage: emitStage,
|
||||
userMessage: userMessage,
|
||||
extra: extra,
|
||||
chatHistory: chatHistory,
|
||||
outChan: outChan,
|
||||
modelName: modelName,
|
||||
dailyRefineConcurrency: dailyRefineConcurrency,
|
||||
}
|
||||
}
|
||||
|
||||
// ── 节点方法引用适配层 ──
|
||||
// 节点方法适配层
|
||||
|
||||
func (r *schedulePlanRunner) planNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runPlanNode(ctx, st, r.chatModel, r.userMessage, r.extra, r.chatHistory, r.emitStage)
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) previewNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runPreviewNode(ctx, st, r.deps, r.emitStage)
|
||||
func (r *schedulePlanRunner) roughBuildNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runRoughBuildNode(ctx, st, r.deps, r.emitStage)
|
||||
}
|
||||
|
||||
// ── ReAct 精排节点适配层 ──
|
||||
|
||||
func (r *schedulePlanRunner) hybridBuildNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runHybridBuildNode(ctx, st, r.deps, r.emitStage)
|
||||
func (r *schedulePlanRunner) dailySplitNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runDailySplitNode(ctx, st, r.emitStage)
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) reactRefineNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runReactRefineNode(ctx, st, r.chatModel, r.outChan, r.modelName, r.emitStage)
|
||||
func (r *schedulePlanRunner) dailyRefineNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runDailyRefineNode(ctx, st, r.chatModel, r.dailyRefineConcurrency, r.emitStage)
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) mergeNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runMergeNode(ctx, st, r.emitStage)
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) weeklyRefineNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runWeeklyRefineNode(ctx, st, r.chatModel, r.outChan, r.modelName, r.emitStage)
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) finalCheckNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
return runFinalCheckNode(ctx, st, r.chatModel, r.emitStage)
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) returnPreviewNode(ctx context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
@@ -74,32 +88,27 @@ func (r *schedulePlanRunner) returnPreviewNode(ctx context.Context, st *Schedule
|
||||
}
|
||||
|
||||
func (r *schedulePlanRunner) exitNode(_ context.Context, st *SchedulePlanState) (*SchedulePlanState, error) {
|
||||
// exit 节点不做任何业务逻辑,仅把当前状态原样透传到 END。
|
||||
return st, nil
|
||||
}
|
||||
|
||||
// ── 分支决策适配层 ──
|
||||
// 分支决策适配层
|
||||
|
||||
func (r *schedulePlanRunner) nextAfterPlan(_ context.Context, st *SchedulePlanState) (string, error) {
|
||||
return selectNextAfterPlan(st), nil
|
||||
}
|
||||
|
||||
// nextAfterPreview 根据 preview 结果决定下一步。
|
||||
// nextAfterRoughBuild 根据粗排构建结果决定后续路径。
|
||||
//
|
||||
// 分支规则:
|
||||
// 1) preview 失败(无候选方案)-> exit
|
||||
// 2) 否则 -> hybridBuild(进入 ReAct 精排路径)
|
||||
func (r *schedulePlanRunner) nextAfterPreview(_ context.Context, st *SchedulePlanState) (string, error) {
|
||||
if st == nil || len(st.CandidatePlans) == 0 {
|
||||
return schedulePlanGraphNodeExit, nil
|
||||
}
|
||||
return schedulePlanGraphNodeHybridBuild, nil
|
||||
}
|
||||
|
||||
// nextAfterHybridBuild 根据 hybridBuild 结果决定下一步。
|
||||
func (r *schedulePlanRunner) nextAfterHybridBuild(_ context.Context, st *SchedulePlanState) (string, error) {
|
||||
// 规则:
|
||||
// 1. 没有可优化条目 -> exit;
|
||||
// 2. task_class_ids >= 2 -> dailySplit(多任务类混排,先做日内并发);
|
||||
// 3. task_class_ids == 1 -> weeklyRefine(单任务类直接周级配平)。
|
||||
func (r *schedulePlanRunner) nextAfterRoughBuild(_ context.Context, st *SchedulePlanState) (string, error) {
|
||||
if st == nil || len(st.HybridEntries) == 0 {
|
||||
return schedulePlanGraphNodeExit, nil
|
||||
}
|
||||
return schedulePlanGraphNodeReactRefine, nil
|
||||
if len(st.TaskClassIDs) >= 2 {
|
||||
return schedulePlanGraphNodeDailySplit, nil
|
||||
}
|
||||
return schedulePlanGraphNodeWeeklyRefine, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user