Files
smartmate/backend/newAgent/prompt/quick_task.go
Losita a3eaa9b2c2 Version: 0.9.61.dev.260501
后端:
1. 主动调度 graph + session bridge 收口——把 dry-run / select / preview / confirm / rerun 串成受限 graph,新增 active_schedule_sessions 缓存与聊天拦截,ready_preview 后释放回自由聊天
2. 会话与通知链路对齐——notification 统一绑定 conversation_id,action_url 指向 /assistant/{conversation_id},会话不存在改回 404 语义,避免 wrong param type 误导排障
3. estimated_sections 写入与主动调度消费链路补齐——任务创建、quick task 与随口记入口都透传估计节数,主动调度只消费落库值

前端:
4. AssistantPanel 最小适配主动调度预览与失败态——复用主动调度卡片/微调弹窗,补历史加载失败可见提示与跨账号会话拦截

文档:
5. 更新主动调度缺口分阶段实施计划和实现方案,标记阶段 0-2 收口并同步接力状态
2026-05-01 20:48:32 +08:00

107 lines
4.9 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 newagentprompt
import (
"fmt"
"strings"
"time"
newagentmodel "github.com/LoveLosita/smartflow/backend/newAgent/model"
"github.com/cloudwego/eino/schema"
)
const quickTaskSystemPrompt = `
你是 SmartMate 的快捷任务助手。用户想记录或查看待办任务。你需要从用户消息中提取操作意图和参数。
你能做的操作:
- create记录一条新任务/提醒
- query查看/筛选任务列表
输出格式(两阶段):
先输出一行决策标签,标签内是 JSON标签之后换行输出给用户看的自然语言正文。
决策标签格式:<SMARTFLOW_DECISION>{JSON}</SMARTFLOW_DECISION>
JSON 字段说明:
- action只能是 create / query / ask
- create 时title 必填deadline_at 必填priority_group 必填,范围 1-4estimated_sections 必填,范围 1-4不确定默认 1urgency_threshold_at 满足条件时填写,条件在下面
- query 时quadrant 可选 1-4keyword 可选limit 可选deadline_after/deadline_before 可选(用于截止时间窗口筛选)
- ask 时question 必填
规则:
1. 优先级1=重要且紧急2=重要不紧急3=简单不重要4=复杂不重要;紧急判定:截止时间距今不超过 48 小时为紧急(1),超过 48 小时为不紧急(2),无截止时间默认 3
2. 信息不足时(如缺少 title输出 {"action":"ask","question":"追问内容"}
3. deadline_at 支持「明天下午3点」「下周一」「2026-04-20 18:00」等格式
4. 未提供的可选字段直接省略,不要填 null 或空字符串
5. JSON 中不要包含 speak 字段,给用户看的话放在 </SMARTFLOW_DECISION> 标签之后
6. 紧急分界时间,即任务从"重要不紧急"自动轮换到"重要且紧急"的时间点;格式同 deadline_at ——当 priority_group=2 时必填,你必须根据 deadline 自动推算一个合理的紧急分界时间(通常为 deadline 前 24-48 小时不要等用户提供priority_group 为 1、3、4 或无截止时间时不要输出此字段
7. query 里出现相对日期窗口(如"明天有什么事要做"优先输出明确边界deadline_after="明天 00:00"deadline_before="后天 00:00",按 [after, before) 语义筛选
示例:
<SMARTFLOW_DECISION>{"action":"create","title":"明天开会","deadline_at":"明天下午3点","estimated_sections":1}</SMARTFLOW_DECISION>
好的,我来帮你记一下。
<SMARTFLOW_DECISION>{"action":"create","title":"下周交报告","deadline_at":"下周五 18:00","priority_group":2,"estimated_sections":2,"urgency_threshold_at":"下周四 09:00"}</SMARTFLOW_DECISION>
好的,我也帮你记一下。
<SMARTFLOW_DECISION>{"action":"query","limit":5}</SMARTFLOW_DECISION>
我帮你查一下当前的任务。
<SMARTFLOW_DECISION>{"action":"query","deadline_after":"明天 00:00","deadline_before":"后天 00:00","limit":10}</SMARTFLOW_DECISION>
我帮你查一下明天要做的事。
<SMARTFLOW_DECISION>{"action":"ask","question":"你想记录什么呢?告诉我具体内容吧。"}</SMARTFLOW_DECISION>
你想记录什么呢?告诉我具体内容吧。`
// BuildQuickTaskSystemPrompt 返回快捷任务阶段的系统提示词。
func BuildQuickTaskSystemPrompt() string {
return strings.TrimSpace(quickTaskSystemPrompt)
}
// BuildQuickTaskMessagesSimple 组装快捷任务阶段的最简 messages无对话历史
func BuildQuickTaskMessagesSimple(userInput string) []*schema.Message {
systemMsg := schema.SystemMessage(BuildQuickTaskSystemPrompt())
userMsg := schema.UserMessage(buildQuickTaskUserPrompt(userInput))
return []*schema.Message{systemMsg, userMsg}
}
func buildQuickTaskUserPrompt(userInput string) string {
var sb strings.Builder
sb.WriteString(fmt.Sprintf("当前时间=%s\n", time.Now().In(time.Local).Format("2006-01-02 15:04")))
sb.WriteString("\n请从用户消息中提取操作意图和参数严格按 SMARTFLOW_DECISION 标签格式输出。\n\n")
trimmedInput := strings.TrimSpace(userInput)
if trimmedInput != "" {
sb.WriteString("用户输入:\n")
sb.WriteString(trimmedInput)
sb.WriteString("\n")
}
return sb.String()
}
// BuildQuickTaskMessages 组装快捷任务阶段的完整 messages含对话历史
func BuildQuickTaskMessages(
ctx *newagentmodel.ConversationContext,
userInput string,
toolSchemas []newagentmodel.ToolSchemaContext,
) []*schema.Message {
return buildUnifiedStageMessages(
ctx,
StageMessagesConfig{
SystemPrompt: BuildQuickTaskSystemPrompt(),
Msg1Content: buildChatConversationMessage(ctx),
Msg2Content: buildQuickTaskWorkspace(toolSchemas),
Msg3Suffix: buildQuickTaskUserPrompt(userInput),
Msg3Role: schema.User,
},
)
}
func buildQuickTaskWorkspace(toolSchemas []newagentmodel.ToolSchemaContext) string {
var sb strings.Builder
sb.WriteString("可用工具:\n")
for _, ts := range toolSchemas {
sb.WriteString(fmt.Sprintf("- %s: %s\n 参数: %s\n", ts.Name, ts.Desc, ts.SchemaText))
}
return sb.String()
}