Version: 0.7.1.dev.260320

🧠 agent智能编排:删除了落库相关逻辑。再次重申:agent智能编排旨在为用户预览排程结果,实际的落库由用户决定,并通过按钮触发常规接口进行落库。目前仅保留 ReAct 精排循环链路(待改进)。
📄 修改了 ReAct 智能精排决策文档相关内容。
🔄 undo:当前 agent 智能排程逻辑待改进。
This commit is contained in:
LoveLosita
2026-03-20 19:40:11 +08:00
parent d3cec2a5b9
commit 059b25872a
12 changed files with 115 additions and 661 deletions

View File

@@ -1,12 +1,9 @@
package service
import (
"context"
"github.com/LoveLosita/smartflow/backend/dao"
outboxinfra "github.com/LoveLosita/smartflow/backend/infra/outbox"
"github.com/LoveLosita/smartflow/backend/inits"
"github.com/LoveLosita/smartflow/backend/model"
"github.com/LoveLosita/smartflow/backend/service/agentsvc"
)
@@ -28,7 +25,7 @@ func NewAgentService(aiHub *inits.AIHub, repo *dao.AgentDAO, taskRepo *dao.TaskD
// NewAgentServiceWithSchedule 在基础 AgentService 上注入排程依赖。
//
// 设计目的:
// 1) 通过函数注入避免 agentsvc 包直接依赖 service 层的 ScheduleService / TaskClassService
// 1) 通过函数注入避免 agentsvc 包直接依赖 service 层的 ScheduleService
// 2) 排程依赖为可选:未注入时排程路由自动回退到普通聊天;
// 3) 保持 NewAgentService 签名不变,向下兼容。
func NewAgentServiceWithSchedule(
@@ -38,7 +35,6 @@ func NewAgentServiceWithSchedule(
agentRedis *dao.AgentCache,
eventPublisher outboxinfra.EventPublisher,
scheduleSvc *ScheduleService,
taskClassSvc *TaskClassService,
) *AgentService {
svc := agentsvc.NewAgentService(aiHub, repo, taskRepo, agentRedis, eventPublisher)
@@ -47,13 +43,6 @@ func NewAgentServiceWithSchedule(
svc.SmartPlanningRawFunc = scheduleSvc.SmartPlanningRaw
svc.HybridScheduleWithPlanFunc = scheduleSvc.HybridScheduleWithPlan
}
if taskClassSvc != nil {
svc.BatchApplyPlansFunc = taskClassSvc.BatchApplyPlans
// GetTaskClassByID 复用 TaskClassService 内部的 DAO 调用。
svc.GetTaskClassByIDFunc = func(ctx context.Context, taskClassID, userID int) (*model.TaskClass, error) {
return taskClassSvc.GetCompleteTaskClassByID(ctx, taskClassID, userID)
}
}
return svc
}

View File

@@ -32,14 +32,8 @@ type AgentService struct {
// SmartPlanningRawFunc 调用粗排算法,同时返回展示结构和已分配的任务项。
// 由 service/agent_bridge.go 在构造时注入 ScheduleService.SmartPlanningRaw。
SmartPlanningRawFunc func(ctx context.Context, userID, taskClassID int) ([]model.UserWeekSchedule, []model.TaskClassItem, error)
// BatchApplyPlansFunc 将排程方案批量落库。
// 由 service/agent_bridge.go 在构造时注入 TaskClassService.BatchApplyPlans。
BatchApplyPlansFunc func(ctx context.Context, taskClassID, userID int, plans *model.UserInsertTaskClassItemToScheduleRequestBatch) error
// GetTaskClassByIDFunc 获取任务类详情(含 Items
// 由 service/agent_bridge.go 在构造时注入。
GetTaskClassByIDFunc func(ctx context.Context, taskClassID, userID int) (*model.TaskClass, error)
// HybridScheduleWithPlanFunc 构建混合日程(既有日程 + 粗排建议),供 ReAct 精排使用。
// 由 service/agent_bridge.go 在构造时注入。可选:未注入时走原有 materialize 路径。
// 由 service/agent_bridge.go 在构造时注入。
HybridScheduleWithPlanFunc func(ctx context.Context, userID, taskClassID int) ([]model.HybridScheduleEntry, []model.TaskClassItem, error)
}

View File

@@ -33,7 +33,7 @@ func (s *AgentService) runSchedulePlanFlow(
modelName string,
) (string, error) {
// 1. 依赖预检:排程依赖函数必须注入,否则无法完成排程链路。
if s.SmartPlanningRawFunc == nil || s.BatchApplyPlansFunc == nil || s.GetTaskClassByIDFunc == nil {
if s.SmartPlanningRawFunc == nil || s.HybridScheduleWithPlanFunc == nil {
return "", errors.New("schedule plan service dependencies are not ready")
}
if selectedModel == nil {
@@ -71,8 +71,6 @@ func (s *AgentService) runSchedulePlanFlow(
State: state,
Deps: scheduleplan.SchedulePlanToolDeps{
SmartPlanningRaw: s.SmartPlanningRawFunc,
BatchApplyPlans: s.BatchApplyPlansFunc,
GetTaskClassByID: s.GetTaskClassByIDFunc,
HybridScheduleWithPlan: s.HybridScheduleWithPlanFunc,
},
UserMessage: userMessage,