Files
smartmate/backend/newAgent/model/chat_contract.go
LoveLosita 8daae62812 Version: 0.9.41.dev.260424
后端:
1. 随口记从 Execute 工具链路迁移到独立 QuickTask 轻量节点——单轮流式提取意图直接调 service,绕过 ReAct 循环
- 新增 QuickTask graph 节点 + Chat→QuickTask→END 分支
- Chat 路由提示词新增 quick_task 路由判别规则,execute 路由收窄为日程类
- Execute 提示词(有 plan / ReAct 两套)移除 quick_note_create / query_tasks 指令
- ToolRegistry 注销 quick_note_create / query_tasks,移除相关依赖与注册
- 依赖注入从 ToolRegistry 改为 Service 层直接注入 QuickTaskDeps

2. urgency_threshold_at 代码兜底 + API 返回补全
- priorityGroup=2 且有 deadline 但 LLM 未填时,自动设为 deadline-24h
- 任务查询接口返回结构补充 UrgencyThresholdAt 字段与转换映射

3. 记忆召回条数 5→10
2026-04-24 14:02:27 +08:00

87 lines
2.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package model
import (
"fmt"
"strings"
)
// ChatRoute 表示 Chat 节点路由决策的目标路径。
type ChatRoute string
const (
// ChatRouteDirectReply 简单任务Chat 节点直接输出回复,不再调用下游节点。
ChatRouteDirectReply ChatRoute = "direct_reply"
// ChatRouteExecute 中等任务:需要用工具处理,直接进 Execute ReAct 循环。
ChatRouteExecute ChatRoute = "execute"
// ChatRouteDeepAnswer 复杂问答需要深度思考但不需工具Chat 节点原地开 thinking 回答。
ChatRouteDeepAnswer ChatRoute = "deep_answer"
// ChatRoutePlan 复杂规划:需要先制定计划,进 Plan 节点。
ChatRoutePlan ChatRoute = "plan"
// ChatRouteQuickTask 快捷任务:随口记增查改删等轻量任务操作,走 QuickTask 轻量路径。
ChatRouteQuickTask ChatRoute = "quick_task"
)
// ChatRoutingDecision 是 Chat 节点单次路由决策的结构化输出。
//
// 职责边界:
// 1. Route 决定后续处理路径;
// 2. NeedsRoughBuild 仅在 route=execute 且满足粗排条件时为 true
// 3. NeedsRefineAfterRoughBuild 仅在 needs_rough_build=true 时有效;
// 4. AllowReorder 表示是否允许打乱 suggested 任务顺序,仅用户明确授权时应为 true
// 5. Thinking 表示下游 Execute 节点是否应开启深度思考;
// 6. Raw 保留控制码原文,供日志排查;
// 7. 用户可见内容speak由流式输出自然产出不由本结构承载。
type ChatRoutingDecision struct {
Route ChatRoute
NeedsRoughBuild bool
NeedsRefineAfterRoughBuild bool
AllowReorder bool
Thinking bool
Raw string
}
// Normalize 统一清洗路由决策中的字符串字段。
func (d *ChatRoutingDecision) Normalize() {
if d == nil {
return
}
d.Route = ChatRoute(strings.TrimSpace(string(d.Route)))
d.Raw = strings.TrimSpace(d.Raw)
}
// Validate 校验路由决策的最小合法性。
func (d *ChatRoutingDecision) Validate() error {
if d == nil {
return fmt.Errorf("chat routing decision 不能为空")
}
d.Normalize()
switch d.Route {
case ChatRouteDirectReply, ChatRouteExecute, ChatRouteDeepAnswer, ChatRoutePlan, ChatRouteQuickTask:
// ok
case "":
return fmt.Errorf("chat routing decision.route 不能为空")
default:
return fmt.Errorf("未知 route: %s", d.Route)
}
// 非 execute 路由不应携带粗排和粗排后微调标记,统一归一化为 false。
if d.Route != ChatRouteExecute {
d.NeedsRoughBuild = false
d.NeedsRefineAfterRoughBuild = false
d.AllowReorder = false
d.Thinking = false
}
// 只有 needs_rough_build=true 时needs_refine_after_rough_build 才有语义。
if !d.NeedsRoughBuild {
d.NeedsRefineAfterRoughBuild = false
}
return nil
}