后端: 1. SSE 心跳保活——解决 Vite dev proxy 在 LLM thinking 静默期判 idle 断连 - api/agent.go:ChatAgent 新增 5 秒 heartbeat ticker,select 增加 heartbeat.C 分支,每 5 秒写入 SSE 注释行 : ping\n\n 并 Flush - service/agentsvc/agent_newagent.go:graph 执行失败时增加 context.Canceled / requestCtx.Err() 判断,客户端断连只记 warn 不推 errChan 也不跑 fallback,消除 "错误通道已满" 日志噪音 2. 随口记工具(quick_note_create)接入新 Agent 链路 - agent/node/quicknote.go:parseOptionalDeadlineWithNow / quickNoteLocation 首字母大写导出,供新链路复用旧链路成熟的时间解析和时区能力 - agent/node/quicknote_tool.go:parseOptionalDeadline / quickNoteLocation 同步导出,补充调用目的注释 - newAgent/tools/quicknote.go:新增 QuickNoteToolHandler,实现新链路 quick_note_create 工具的参数校验、时间解析、写库调用 - newAgent/tools/registry.go:DefaultRegistryDeps 新增 QuickNote 字段;新增 RequiresScheduleState 方法和 scheduleFreeTools 集合;注册 quick_note_create 工具(不加入 writeTools,不走 confirm 确认) - cmd/start.go:NewDefaultRegistryWithDeps 注入 QuickNote.CreateTask 闭包,捕获 taskRepo 实例写库 3. Execute 节点随口记 speak 清空 + 非 ScheduleState 工具支持 - newAgent/node/execute.go:新增非写工具 confirm→continue 自动降级逻辑;新增 quick_note_create speak 强制清空,收口统一交给 deliver,避免 execute + deliver 重复废话 - newAgent/node/execute.go:executeToolCall / executePendingTool 中 scheduleState nil 检查改为仅拦截 RequiresScheduleState 的工具;为不依赖 ScheduleState 的工具自动注入 _user_id 参数 - newAgent/prompt/execute.go:有 plan / ReAct 两套系统 prompt 中,"写操作"规则细化为"日程写操作";新增 quick_note_create 专属执行规则:speak 必须留空,收口由 deliver 完成,调用成功后可 continue 处理多任务 - newAgent/prompt/chat.go:execute 路由描述补充"记录任务/提醒"场景 前端: 1. Vite dev proxy SSE 透传配置 - vite.config.ts:/api 代理新增 configure 回调,设置 x-accel-buffering: no 和 cache-control: no-cache,禁用代理缓冲 2.SSE 流式处理修复 - AssistantPanel.vue:reasoning_content 守卫放宽,移除 !assistantMessage.content.trim() 外层条件,正文回流后仍允许追加 reasoning(工具调用摘要、阶段状态等),不再吞掉 execute/deliver 的 reasoning_content - AssistantPanel.vue:流式完成后跳过 loadConversationMessages,避免 persistVisibleMessage 尚未落库时 merge 产生重复或丢失 仓库:无
576 lines
53 KiB
Plaintext
576 lines
53 KiB
Plaintext
GOROOT=C:\Program Files\Go #gosetup
|
||
GOPATH=C:\Users\Dev\go #gosetup
|
||
"C:\Program Files\Go\bin\go.exe" build -o C:\Users\Dev\AppData\Local\JetBrains\GoLand2025.3\tmp\GoLand\___6go_build_main_go.exe D:\SmartFlow-Agent\backend\main.go #gosetup
|
||
C:\Users\Dev\AppData\Local\JetBrains\GoLand2025.3\tmp\GoLand\___6go_build_main_go.exe #gosetup
|
||
2026/04/18 10:03:36 Config loaded successfully
|
||
2026/04/18 10:03:45 Database connected successfully
|
||
2026/04/18 10:03:45 Database auto migration completed
|
||
2026/04/18 10:03:45 RAG runtime initialized: store=milvus embed=eino reranker=noop
|
||
2026/04/18 10:03:45 outbox engine starting: topic=smartflow.agent.outbox brokers=[localhost:9092] retry_scan=1s batch=100
|
||
2026/04/18 10:03:45 Kafka topic is ready: smartflow.agent.outbox
|
||
2026/04/18 10:03:45 Outbox event bus started
|
||
2026/04/18 10:03:45 Memory worker started
|
||
2026/04/18 10:03:45 WebSearch provider: bocha
|
||
2026/04/18 10:03:45 Routes setup completed
|
||
2026/04/18 10:03:45 Server starting on port 8080...
|
||
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
|
||
|
||
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
|
||
- using env: export GIN_MODE=release
|
||
- using code: gin.SetMode(gin.ReleaseMode)
|
||
|
||
[GIN-debug] GET /api/v1/health --> github.com/LoveLosita/smartflow/backend/routers.RegisterRouters.func1 (3 handlers)
|
||
[GIN-debug] POST /api/v1/user/register --> github.com/LoveLosita/smartflow/backend/api.(*UserHandler).UserRegister-fm (3 handlers)
|
||
[GIN-debug] POST /api/v1/user/login --> github.com/LoveLosita/smartflow/backend/api.(*UserHandler).UserLogin-fm (3 handlers)
|
||
[GIN-debug] POST /api/v1/user/refresh-token --> github.com/LoveLosita/smartflow/backend/api.(*UserHandler).RefreshTokenHandler-fm (3 handlers)
|
||
[GIN-debug] POST /api/v1/user/logout --> github.com/LoveLosita/smartflow/backend/api.(*UserHandler).UserLogout-fm (5 handlers)
|
||
[GIN-debug] POST /api/v1/task/create --> github.com/LoveLosita/smartflow/backend/api.(*TaskHandler).AddTask-fm (6 handlers)
|
||
[GIN-debug] PUT /api/v1/task/complete --> github.com/LoveLosita/smartflow/backend/api.(*TaskHandler).CompleteTask-fm (6 handlers)
|
||
[GIN-debug] PUT /api/v1/task/undo-complete --> github.com/LoveLosita/smartflow/backend/api.(*TaskHandler).UndoCompleteTask-fm (6 handlers)
|
||
[GIN-debug] GET /api/v1/task/get --> github.com/LoveLosita/smartflow/backend/api.(*TaskHandler).GetUserTasks-fm (5 handlers)
|
||
[GIN-debug] POST /api/v1/course/validate --> github.com/LoveLosita/smartflow/backend/api.(*CourseHandler).CheckUserCourse-fm (5 handlers)
|
||
[GIN-debug] POST /api/v1/course/import --> github.com/LoveLosita/smartflow/backend/api.(*CourseHandler).AddUserCourses-fm (6 handlers)
|
||
[GIN-debug] POST /api/v1/task-class/add --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).UserAddTaskClass-fm (6 handlers)
|
||
[GIN-debug] GET /api/v1/task-class/list --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).UserGetTaskClassInfos-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/task-class/get --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).UserGetCompleteTaskClass-fm (5 handlers)
|
||
[GIN-debug] PUT /api/v1/task-class/update --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).UserUpdateTaskClass-fm (6 handlers)
|
||
[GIN-debug] POST /api/v1/task-class/insert-into-schedule --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).UserAddTaskClassItemIntoSchedule-fm (6 handlers)
|
||
[GIN-debug] DELETE /api/v1/task-class/delete-item --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).DeleteTaskClassItem-fm (6 handlers)
|
||
[GIN-debug] DELETE /api/v1/task-class/delete-class --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).DeleteTaskClass-fm (6 handlers)
|
||
[GIN-debug] PUT /api/v1/task-class/apply-batch-into-schedule --> github.com/LoveLosita/smartflow/backend/api.(*TaskClassHandler).UserInsertBatchTaskClassItemsIntoSchedule-fm (6 handlers)
|
||
[GIN-debug] GET /api/v1/schedule/today --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).GetUserTodaySchedule-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/schedule/week --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).GetUserWeeklySchedule-fm (5 handlers)
|
||
[GIN-debug] DELETE /api/v1/schedule/delete --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).DeleteScheduleEvent-fm (6 handlers)
|
||
[GIN-debug] GET /api/v1/schedule/recent-completed --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).GetUserRecentCompletedSchedules-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/schedule/current --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).GetUserOngoingSchedule-fm (5 handlers)
|
||
[GIN-debug] DELETE /api/v1/schedule/undo-task-item --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).UserRevocateTaskItemFromSchedule-fm (6 handlers)
|
||
[GIN-debug] GET /api/v1/schedule/smart-planning --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).SmartPlanning-fm (5 handlers)
|
||
[GIN-debug] POST /api/v1/schedule/smart-planning-multi --> github.com/LoveLosita/smartflow/backend/api.(*ScheduleAPI).SmartPlanningMulti-fm (5 handlers)
|
||
[GIN-debug] POST /api/v1/agent/chat --> github.com/LoveLosita/smartflow/backend/api.(*AgentHandler).ChatAgent-fm (6 handlers)
|
||
[GIN-debug] GET /api/v1/agent/conversation-meta --> github.com/LoveLosita/smartflow/backend/api.(*AgentHandler).GetConversationMeta-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/agent/conversation-list --> github.com/LoveLosita/smartflow/backend/api.(*AgentHandler).GetConversationList-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/agent/conversation-history --> github.com/LoveLosita/smartflow/backend/api.(*AgentHandler).GetConversationHistory-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/agent/schedule-preview --> github.com/LoveLosita/smartflow/backend/api.(*AgentHandler).GetSchedulePlanPreview-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/agent/context-stats --> github.com/LoveLosita/smartflow/backend/api.(*AgentHandler).GetContextStats-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/memory/items --> github.com/LoveLosita/smartflow/backend/api.(*MemoryHandler).ListItems-fm (5 handlers)
|
||
[GIN-debug] GET /api/v1/memory/items/:id --> github.com/LoveLosita/smartflow/backend/api.(*MemoryHandler).GetItem-fm (5 handlers)
|
||
[GIN-debug] POST /api/v1/memory/items --> github.com/LoveLosita/smartflow/backend/api.(*MemoryHandler).CreateItem-fm (6 handlers)
|
||
[GIN-debug] PATCH /api/v1/memory/items/:id --> github.com/LoveLosita/smartflow/backend/api.(*MemoryHandler).UpdateItem-fm (6 handlers)
|
||
[GIN-debug] DELETE /api/v1/memory/items/:id --> github.com/LoveLosita/smartflow/backend/api.(*MemoryHandler).DeleteItem-fm (6 handlers)
|
||
[GIN-debug] POST /api/v1/memory/items/:id/restore --> github.com/LoveLosita/smartflow/backend/api.(*MemoryHandler).RestoreItem-fm (6 handlers)
|
||
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
|
||
Please check https://github.com/gin-gonic/gin/blob/master/docs/doc.md#dont-trust-all-proxies for details.
|
||
[GIN-debug] Listening and serving HTTP on :8080
|
||
[GIN] 2026/04/18 - 10:03:47 | 200 | 56.2777ms | 127.0.0.1 | GET "/api/v1/agent/conversation-list?page=1&page_size=12&limit=12&status=active"
|
||
[GIN] 2026/04/18 - 10:03:48 | 200 | 51.0388ms | 127.0.0.1 | GET "/api/v1/agent/conversation-history?conversation_id=1655dd9b-2c4c-4b56-a712-f34c11b2634d"
|
||
[GIN] 2026/04/18 - 10:03:48 | 200 | 2.0207ms | 127.0.0.1 | GET "/api/v1/agent/conversation-meta?conversation_id=1655dd9b-2c4c-4b56-a712-f34c11b2634d"
|
||
[GIN] 2026/04/18 - 10:03:48 | 200 | 47.1267ms | 127.0.0.1 | GET "/api/v1/agent/context-stats?conversation_id=1655dd9b-2c4c-4b56-a712-f34c11b2634d"
|
||
[GIN] 2026/04/18 - 10:03:56 | 200 | 49.8019ms | 127.0.0.1 | GET "/api/v1/agent/conversation-history?conversation_id=7c7454e9-e335-4073-b0a2-dba0fdb61831"
|
||
[GIN] 2026/04/18 - 10:03:56 | 200 | 2.3995ms | 127.0.0.1 | GET "/api/v1/agent/context-stats?conversation_id=7c7454e9-e335-4073-b0a2-dba0fdb61831"
|
||
[GIN] 2026/04/18 - 10:03:56 | 200 | 9.1263ms | 127.0.0.1 | GET "/api/v1/agent/conversation-meta?conversation_id=7c7454e9-e335-4073-b0a2-dba0fdb61831"
|
||
[GIN] 2026/04/18 - 10:03:57 | 200 | 2.2448ms | 127.0.0.1 | GET "/api/v1/agent/conversation-meta?conversation_id=905d0549-c099-42aa-8ab1-e5153543e6d0"
|
||
[GIN] 2026/04/18 - 10:03:57 | 200 | 48.1556ms | 127.0.0.1 | GET "/api/v1/agent/context-stats?conversation_id=905d0549-c099-42aa-8ab1-e5153543e6d0"
|
||
[GIN] 2026/04/18 - 10:03:57 | 200 | 48.1556ms | 127.0.0.1 | GET "/api/v1/agent/conversation-history?conversation_id=905d0549-c099-42aa-8ab1-e5153543e6d0"
|
||
[GIN] 2026/04/18 - 10:03:57 | 200 | 49.2902ms | 127.0.0.1 | GET "/api/v1/agent/conversation-history?conversation_id=929fc727-291b-4f18-a5b7-aeda2abde1e3"
|
||
[GIN] 2026/04/18 - 10:03:57 | 200 | 1.4866ms | 127.0.0.1 | GET "/api/v1/agent/context-stats?conversation_id=929fc727-291b-4f18-a5b7-aeda2abde1e3"
|
||
[GIN] 2026/04/18 - 10:03:57 | 200 | 4.8978ms | 127.0.0.1 | GET "/api/v1/agent/conversation-meta?conversation_id=929fc727-291b-4f18-a5b7-aeda2abde1e3"
|
||
|
||
2026/04/18 10:04:06 D:/SmartFlow-Agent/backend/dao/agent.go:211 record not found
|
||
[47.428ms] [rows:0] SELECT * FROM `agent_chats` WHERE user_id = 1 AND chat_id = '6c0edfe9-2dba-4927-905b-bfdb06e19e2a' ORDER BY `agent_chats`.`id` LIMIT 1
|
||
2026/04/18 10:04:06 [GORM-Cache] Invalidated conversation history cache for user 1 conversation 6c0edfe9-2dba-4927-905b-bfdb06e19e2a
|
||
2026/04/18 10:04:06 [DEBUG] loadOrCreateRuntimeState chatID=6c0edfe9-2dba-4927-905b-bfdb06e19e2a ok=false err=<nil> hasRuntime=false hasPending=false hasCtx=false hasSchedule=false hasOriginal=false
|
||
2026/04/18 10:04:06 [INFO] memory prefetch: 启动后台检索 goroutine user=1 chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a
|
||
2026/04/18 10:04:06 [COMPACT:chat] token budget check: total=1619 budget=80000 over=false compactMsg1=false compactMsg2=false (msg0=1512 msg1=20 msg2=14 msg3=73)
|
||
2026/04/18 10:04:06 [DEBUG] chat LLM context begin phase=routing chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=0 message_count=4
|
||
----- message[0] -----
|
||
role: system
|
||
content:
|
||
你叫 SmartMate,是时伴(SmartMate)的中文 AI 排程伙伴,面向大学生提供陪伴式日程管理与日常协助。
|
||
你擅长课表与任务安排、任务管理、学习规划和随口记,也可以正常回答日常问答、生活建议、信息整理、分析讨论等非排程问题。
|
||
你的目标是像一个越用越懂用户的伙伴一样,结合历史对话、长期记忆和当前上下文,给出贴心、清晰、可信的帮助。
|
||
你的回复应当专业、自然、有陪伴感,偶尔可以带一点轻松幽默。
|
||
如果用户的问题与日程无关,不要因为“不属于排程”就拒绝、回避或强行转到任务安排;只要不需要工具且你有把握,就直接回答。
|
||
重要约束:你无法直接写入数据库。除非系统明确告知“任务已落库成功”,否则禁止使用“已安排/已记录/已帮你记下”等完成态表述。
|
||
|
||
你是 SmartMate 的聊天路由助手。SmartMate 是时伴(SmartMate)的中文 AI 排程伙伴,面向大学生提供陪伴式日程管理与日常协助;它擅长日程安排、任务管理与学习规划,但不只会做排程。你的回复必须以路由控制码开头,控制码后紧跟用户可见的内容。
|
||
|
||
路由规则:
|
||
- direct_reply:纯闲聊、简单问答、轻量生活建议、打招呼、感谢等不需要工具、也不需要长链路思考的请求。控制码后直接输出完整回复。
|
||
- execute:需要用工具处理的请求(记录任务/提醒、查询日程、移动课程、排课等),但不需要先制定计划。控制码后输出简短确认。
|
||
- deep_answer:复杂问题但不需要工具(如分析建议、知识解释、方案比较、深度讨论等),需要深度思考后回答。控制码后不要输出任何占位过渡语,后端会直接进入第二次正式回答。
|
||
- plan:用户明确要求先制定计划,或涉及多阶段复杂规划。控制码后输出简短确认。
|
||
|
||
通用回答约束:
|
||
- 非日程、非任务类问题,只要不需要工具,也应当正常回答。
|
||
- 不要因为用户的问题不涉及排程,就说自己“只能处理日程/任务安排”。
|
||
- 不要把普通问答、生活建议、开放式讨论,硬拐成排程请求。
|
||
- route=direct_reply 时,控制码后的可见内容应直接回应用户问题,而不是先讲能力边界。
|
||
- route=deep_answer 时,只输出控制码即可,不要补“让我想想”“这是个好问题”之类的占位话术。
|
||
|
||
粗排判断:当用户意图包含"批量安排/排课/把任务类排进日程"等批量调度需求时,可设置 rough_build=true;后端会结合真实请求范围决定是否真正进入粗排。
|
||
二次粗排约束(强约束):
|
||
- 若上下文已出现 rough_build_done,且用户未明确要求"重新粗排/从头重排",必须设置 rough_build=false。
|
||
- "移动/微调/优化/均匀化/调顺序"等请求默认视为 refine,不得再次触发 rough build。
|
||
粗排后微调判断:
|
||
- 仅当 rough_build=true 时才判断 refine。
|
||
- 若用户明确提出优化目标/偏好(如"尽量均衡""周三别太满""某门课往后挪"),设 refine=true。
|
||
- 若用户只要求"先排进去/给初稿",未提出微调目标,设 refine=false。
|
||
顺序授权判断:
|
||
- reorder 仅在用户明确说明"允许打乱顺序/顺序不重要"时才为 true。
|
||
- 用户明确要求"保持顺序/不要打乱"时必须为 false。
|
||
- 若用户未明确提及顺序,一律为 false。
|
||
深度思考判断:
|
||
- thinking 仅在 route=execute 时有效。
|
||
- 当用户请求涉及复杂推理、多条件约束、需要深度分析后才能执行的操作时,设 thinking=true。
|
||
- 简单查询、单步操作设 thinking=false。
|
||
|
||
输出格式(严格两段式):
|
||
第一段(控制码,用户不可见,后端会截取):
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="direct_reply|execute|deep_answer|plan" rough_build="false" refine="false" reorder="false" thinking="false"/>
|
||
第二段(紧接控制码之后,用户可见):
|
||
根据路由输出对应内容。
|
||
|
||
属性说明(仅 route=execute 时有效,其余路由省略这些属性):
|
||
- rough_build:是否需要粗排
|
||
- refine:粗排后是否需要微调
|
||
- reorder:是否允许打乱顺序
|
||
- thinking:后续执行阶段是否需要深度思考
|
||
|
||
合法示例:
|
||
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="direct_reply"/>
|
||
当然可以,我先直接回答你这个问题。
|
||
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="execute"/>
|
||
好的,我来帮你看看今天的安排。
|
||
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="execute" rough_build="true" refine="false" reorder="false" thinking="false"/>
|
||
好的,我来帮你排课。
|
||
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="execute" rough_build="true" refine="true" reorder="false" thinking="true"/>
|
||
好的,我来帮你排课并按你的偏好做微调。
|
||
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="deep_answer"/>
|
||
|
||
<SMARTFLOW_ROUTE nonce="给定nonce" route="plan"/>
|
||
明白,我来帮你制定一个完整的学习计划。
|
||
|
||
禁止输出任何 JSON、markdown 代码块或额外解释。nonce 必须精确使用给定值。
|
||
|
||
----- message[1] -----
|
||
role: assistant
|
||
content:
|
||
真实对话记录:
|
||
user: "提醒我明天中午吃乡村基"
|
||
|
||
----- message[2] -----
|
||
role: assistant
|
||
content:
|
||
路由补充:
|
||
- 暂无额外流程标记。
|
||
|
||
----- message[3] -----
|
||
role: user
|
||
content:
|
||
nonce=932ef523-3e20-4595-8a09-2ff4319f0394
|
||
当前时间=2026-04-18 10:04
|
||
|
||
请基于最近真实对话和本轮输入选择最合适的路由,并严格按系统约定输出控制码。
|
||
|
||
用户本轮输入:
|
||
提醒我明天中午吃乡村基
|
||
|
||
|
||
[DEBUG] chat LLM context end phase=routing chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=0
|
||
2026/04/18 10:04:06 rag level=info component=store operation=ensure_collection action=search collection=smartflow_rag_chunks corpus=memory latency_ms=5 metric_type=COSINE status=already_exists store=milvus vector_dim=1024
|
||
2026/04/18 10:04:06 rag level=error component=store operation=search action=search collection=smartflow_rag_chunks corpus=memory error=unsupported milvus filter key: status error_code=RAG_ERROR filter_count=3 latency_ms=5 status=failed store=milvus top_k=10 vector_dim=1024
|
||
2026/04/18 10:04:06 rag level=error component=runtime operation=retrieve action=search corpus=memory error=unsupported milvus filter key: status error_code=RAG_ERROR latency_ms=215 query_len=33 status=failed threshold=0.55 top_k=10
|
||
2026/04/18 10:04:07 memory level=info component=read operation=retrieve dedup_drop_count=0 degraded=true final_count=5 legacy_hit_count=0 pinned_hit_count=0 query_len=33 rag_fallback_used=true read_mode=hybrid semantic_hit_count=10 success=true user_id=1
|
||
2026/04/18 10:04:07 [INFO] memory prefetch: 后台检索完成 user=1 count=5
|
||
2026/04/18 10:04:07 outbox due messages=1, start dispatch
|
||
2026/04/18 10:04:08 [GORM-Cache] Invalidated conversation history cache for user 1 conversation 6c0edfe9-2dba-4927-905b-bfdb06e19e2a
|
||
2026/04/18 10:04:09 outbox due messages=1, start dispatch
|
||
2026/04/18 10:04:09 [DEBUG] chat routing chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a route=execute needs_rough_build=false needs_refine_after_rough_build=false allow_reorder=false thinking=false has_rough_build_done=false task_class_count=0 raw=<SMARTFLOW_ROUTE nonce="932ef523-3e20-4595-8a09-2ff4319f0394" route="execute" rough_build="false" refine="false" reorder="false" thinking="false"/>
|
||
2026/04/18 10:04:10 [COMPACT:execute] token budget check: total=4060 budget=80000 over=false compactMsg1=false compactMsg2=false (msg0=3694 msg1=45 msg2=19 msg3=302)
|
||
2026/04/18 10:04:10 [DEBUG] execute LLM context begin phase=decision chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=1 message_count=4
|
||
----- message[0] -----
|
||
role: system
|
||
content:
|
||
你叫 SmartMate,是时伴(SmartMate)的中文 AI 排程伙伴,面向大学生提供陪伴式日程管理与日常协助。
|
||
你擅长课表与任务安排、任务管理、学习规划和随口记,也可以正常回答日常问答、生活建议、信息整理、分析讨论等非排程问题。
|
||
你的目标是像一个越用越懂用户的伙伴一样,结合历史对话、长期记忆和当前上下文,给出贴心、清晰、可信的帮助。
|
||
你的回复应当专业、自然、有陪伴感,偶尔可以带一点轻松幽默。
|
||
如果用户的问题与日程无关,不要因为“不属于排程”就拒绝、回避或强行转到任务安排;只要不需要工具且你有把握,就直接回答。
|
||
重要约束:你无法直接写入数据库。除非系统明确告知“任务已落库成功”,否则禁止使用“已安排/已记录/已帮你记下”等完成态表述。
|
||
|
||
你是 SmartMate 的执行器,当前处于自由执行模式(无预定义 plan 步骤)。
|
||
|
||
阶段事实(强约束):
|
||
1. 若上下文给出"粗排已完成/rough_build_done",表示目标任务类已经进入 suggested/existing,不是待排入状态。
|
||
2. 当前阶段目标是"微调",不是"重新粗排"。
|
||
3. 若上下文明确"当前未收到明确微调偏好/本轮先收口",应直接结束而不是继续优化循环。
|
||
4. 若用户提出了二次微调方向,本轮优先目标就是满足该方向。
|
||
|
||
你可以做什么:
|
||
1. 你可以基于用户给定的二次微调方向,对 suggested 做定向微调。
|
||
2. existing 属于已安排事实层,可用于冲突判断和参考,不作为 move/batch_move/spread_even 的目标。
|
||
3. 你可以先调用读工具补充必要事实(例如 get_overview/query_target_tasks/query_available_slots/get_task_info)。
|
||
4. 你可以在需要日程写操作时提出 confirm(move/swap/unplace/batch_move/spread_even)。quick_note_create 不需要确认,用 action=continue;若信息足够,必须显式填写 priority_group,若信息不足则先 ask_user。
|
||
5. 只有用户明确允许打乱顺序时,才可使用 min_context_switch。
|
||
6. 多任务处理默认使用队列链路:先 query_target_tasks(enqueue=true) 入队,再 queue_pop_head 逐项处理。
|
||
|
||
你不要做什么:
|
||
1. 不要假设任务还没排进去,然后改成逐个手动 place。
|
||
2. 不要伪造工具结果。
|
||
3. 不要重复做同类查询而没有新增结论;连续两轮同类读查询后,必须转入执行、ask_user,或明确阻塞原因。
|
||
4. 若工具结果与已知事实明显冲突(如无写操作却从"有任务"变成"0任务"),先自我纠错并重查一次,不要直接 ask_user。
|
||
5. 不要连续两轮调用"同一读工具 + 等价 arguments";若上一轮已成功返回,下一轮必须换工具或进入 confirm。
|
||
6. 若已明确"本轮先收口",不要继续调用 query_available_slots/move 做无目标微调。
|
||
7. 若用户明确了微调方向,不要只做"局部看起来更空"的随机调整;每次改动都要能对应到该方向。
|
||
8. 若顺序策略为"保持顺序",禁止调用 min_context_switch。
|
||
9. 不要在同一轮构造大规模 batch_move;batch_move 最多 2 条,超过请走队列逐项处理。
|
||
10. 未调用 queue_pop_head 获取 current 前,不要调用 queue_apply_head_move。
|
||
11. 工具参数必须严格使用 schema 字段,禁止自造别名;例如 day_from/day_to 非法,必须改用 day_start/day_end。
|
||
12. web_search 仅在"制定学习计划需要查外部资料"时使用(如考试日期、课程信息、校历政策等);日程排布本身(place/move/swap)不需要搜索。
|
||
13. web_search 拿到 summary 后通常已够用;仅当需要页面详细内容时才调用 web_fetch。
|
||
|
||
执行规则:
|
||
1. 只输出严格 JSON,不要输出 markdown,不要在 JSON 外补充文本。
|
||
2. 读操作:action=continue + tool_call。
|
||
3. 写操作(日程变更,如 place/move/swap/batch_move/unplace/spread_even/min_context_switch):action=confirm + tool_call。
|
||
4. quick_note_create(记录任务/提醒):若信息足够,action=continue + tool_call,并显式填写 priority_group;若信息不足且无法可靠推断,action=ask_user 先追问。
|
||
5. 缺关键上下文且无法通过工具补齐:action=ask_user。
|
||
6. 任务完成:action=done,并在 goal_check 总结完成证据。
|
||
7. 流程应正式终止:action=abort。
|
||
|
||
补充 JSON 约束:
|
||
1. 只输出当前 action 真正需要的字段;无关字段直接省略,不要用 ""、{}、[]、null 占位。
|
||
2. 若输出 tool_call,参数字段名只能是 arguments,禁止写成 parameters。
|
||
3. tool_call 只能是单个对象:{"name":"工具名","arguments":{...}},不能输出数组。
|
||
4. 只有 action=abort 时才允许输出 abort 字段;非 abort 动作不要输出 abort。
|
||
5. action=continue / ask_user / confirm 时,speak 必须是非空自然语言。
|
||
|
||
可用工具(简表):
|
||
1. batch_move:原子性批量移动多个任务(仅 suggested,最多2条),全部成功才生效。若含 existing/pending 或任一冲突将整批失败回滚。
|
||
参数:moves(必填,array)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:批量移动完成,2个任务全部成功。(单次最多2条)
|
||
2. get_overview:获取规划窗口总览(任务视角,全量返回):保留课程占位统计,展开任务清单(过滤课程明细)。
|
||
参数:{}
|
||
返回类型:string(自然语言文本)
|
||
返回示例:规划窗口共27天...课程占位条目34个...任务清单(全量,已过滤课程)...
|
||
3. get_task_info:查询单个任务详细信息,包括类别、状态、占用时段、嵌入关系。
|
||
参数:task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:[35]第一章随机事件与概率 | 状态:已预排(suggested) | 占用时段:第3天第5-6节
|
||
4. min_context_switch:在指定任务集合内重排 suggested 任务,尽量让同类任务连续以减少上下文切换。仅在用户明确允许打乱顺序时使用。task_ids 必填(兼容 task_id)。
|
||
参数:task_id(可选,int);task_ids(必填,array)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:最少上下文切换重排完成:共处理 6 个任务,上下文切换次数 5 -> 2。
|
||
5. move:将一个已预排任务(仅 suggested)移动到新位置。existing 属于已安排事实层,不参与 move。task_id/new_day/new_slot_start 必填。
|
||
参数:new_day(必填,int);new_slot_start(必填,int);task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:已将 [35]... 从第3天第5-6节移至第5天第3-4节。
|
||
6. place:将一个待安排任务预排到指定位置。自动检测可嵌入宿主。task_id/day/slot_start 必填。
|
||
参数:day(必填,int);slot_start(必填,int);task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:已将 [35]... 预排到第5天第3-4节。
|
||
7. query_available_slots:查询候选空位池(先返回纯空位,不足再补可嵌入位),适合 move 前的落点筛选。
|
||
参数:after_section(可选,int);allow_embed(可选,bool);before_section(可选,int);day(可选,int);day_end(可选,int);day_of_week(可选,array);day_scope(可选,string:all/workday/weekend);day_start(可选,int);duration(可选,int);exclude_sections(可选,array);limit(可选,int);section_from(可选,int);section_to(可选,int);slot_type(可选,string);slot_types(可选,array);span(可选,int);week(可选,int);week_filter(可选,array);week_from(可选,int);week_to(可选,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"query_available_slots","count":12,"strict_count":8,"embedded_count":4,"slots":[{"day":5,"week":12,"day_of_week":3,"slot_start":1,"slot_end":2,"slot_type":"empty"}]}
|
||
8. query_range:查看某天或某时段的细粒度占用详情。day 必填,slot_start/slot_end 选填(不填查整天)。
|
||
参数:day(必填,int);slot_end(可选,int);slot_start(可选,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:第5天第3-6节:第3节空、第4节空...
|
||
9. query_target_tasks:查询候选任务集合,可按 status/week/day/task_id/category 筛选;默认自动入队,供后续 queue_pop_head 逐项处理。
|
||
参数:category(可选,string);day(可选,int);day_end(可选,int);day_of_week(可选,array);day_scope(可选,string:all/workday/weekend);day_start(可选,int);enqueue(可选,bool);limit(可选,int);reset_queue(可选,bool);status(可选,string:all/existing/suggested/pending);task_id(可选,int);task_ids(可选,array);task_item_id(可选,int);task_item_ids(可选,array);week(可选,int);week_filter(可选,array);week_from(可选,int);week_to(可选,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"query_target_tasks","count":6,"status":"suggested","enqueue":true,"enqueued":6,"queue":{"pending_count":6},"items":[{"task_id":35,"name":"示例任务","status":"suggested","slots":[{"day":3,"week":12,"day_of_week":1,"slot_start":5,"slot_end":6}]}]}
|
||
10. queue_apply_head_move:将当前队首任务移动到指定位置并自动出队。仅作用于 current,不接受 task_id。new_day/new_slot_start 必填。
|
||
参数:new_day(必填,int);new_slot_start(必填,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_apply_head_move","success":true,"task_id":35,"pending_count":4,"completed_count":2,"result":"已将 [35]... 从第3天第5-6节移至第5天第3-4节。"}
|
||
11. queue_pop_head:弹出并返回当前队首任务;若已有 current 则复用,保证一次只处理一个任务。
|
||
参数:{}
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_pop_head","has_head":true,"pending_count":5,"current":{"task_id":35,"name":"示例任务","status":"suggested","slots":[{"day":3,"week":12,"day_of_week":1,"slot_start":5,"slot_end":6}]}}
|
||
12. queue_skip_head:跳过当前队首任务(不改日程),将其标记为 skipped 并继续后续队列。
|
||
参数:reason(可选,string)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_skip_head","success":true,"skipped_task_id":35,"pending_count":4,"skipped_count":1}
|
||
13. queue_status:查看当前待处理队列状态(pending/current/completed/skipped)。
|
||
参数:{}
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_status","pending_count":5,"completed_count":1,"skipped_count":0,"current_task_id":35,"current_attempt":1}
|
||
14. quick_note_create:记录一条任务/提醒/待办事项到用户的任务列表。支持中文相对时间(如“明天下午3点”、“下周一”)。title 必填。记录成功后,回复时应包含一句与任务内容相关的轻松跟进话术(不超过30字),类似朋友间的友好调侃。
|
||
参数:deadline_at(可选,string);priority_group(可选,int);title(必填,string)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:自然语言结果(成功/失败原因/关键数据摘要)。
|
||
15. spread_even:在给定任务集合内做均匀化铺开:先按筛选条件收集候选坑位,再规划并原子落地。task_ids 必填(兼容 task_id)。
|
||
参数:after_section(可选,int);allow_embed(可选,bool);before_section(可选,int);day(可选,int);day_end(可选,int);day_of_week(可选,array);day_scope(可选,string:all/workday/weekend);day_start(可选,int);exclude_sections(可选,array);limit(可选,int);slot_type(可选,string);slot_types(可选,array);task_id(可选,int);task_ids(必填,array);week(可选,int);week_filter(可选,array);week_from(可选,int);week_to(可选,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:均匀化调整完成:共处理 6 个任务,候选坑位 24 个。
|
||
16. swap:交换两个已落位任务的位置。两个任务必须时长相同。task_a/task_b 必填。
|
||
参数:task_a(必填,int);task_b(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:交换完成:[35]... ↔ [36]...
|
||
17. unplace:将一个已落位任务移除,恢复为待安排状态。会自动清理嵌入关系。task_id 必填。
|
||
参数:task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:已将 [35]... 移除,恢复为待安排状态。
|
||
18. web_fetch:抓取指定 URL 的正文内容并做最小 HTML 清洗。url 必填。
|
||
参数:max_chars(可选,int);url(必填,string)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"web_fetch","url":"https://example.com/page","title":"页面标题","content":"正文内容...","truncated":false}
|
||
19. web_search:Web 搜索:根据 query 返回结构化检索结果(标题/摘要/URL/来源域名/时间)。query 必填。
|
||
参数:domain_allow(可选,array);query(必填,string);recency_days(可选,int);top_k(可选,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"web_search","query":"检索关键词","count":2,"items":[{"title":"搜索结果标题","url":"https://example.com/page","snippet":"摘要片段...","domain":"example.com","published_at":"2025-04-10"}]}
|
||
|
||
----- message[1] -----
|
||
role: assistant
|
||
content:
|
||
历史上下文:
|
||
对话历史:
|
||
user: "提醒我明天中午吃乡村基"
|
||
- 阶段锚点:按当前工具事实推进,不做无依据操作。
|
||
|
||
----- message[2] -----
|
||
role: assistant
|
||
content:
|
||
当轮 ReAct Loop 记录:
|
||
- 已清空(新一轮 loop 准备中)。
|
||
|
||
----- message[3] -----
|
||
role: system
|
||
content:
|
||
当前执行状态:
|
||
- 当前轮次:1/60
|
||
- 当前模式:自由执行(无预定义步骤)
|
||
- 啥时候结束Loop:你可以根据工具调用记录自行判断。
|
||
- 非目标:不重新粗排、不修改无关任务类。
|
||
- 参数纪律:工具参数必须严格使用 schema 字段;若返回'参数非法',需先改参再继续。
|
||
- 顺序策略:默认保持 suggested 相对顺序,禁止调用 min_context_switch。
|
||
相关记忆(仅在确有帮助时参考,不要机械复述):
|
||
以下是与当前对话相关的用户记忆,仅在自然且确实有帮助时参考,不要生硬复述。
|
||
- [约束] 用户需要智能编排任务,明确要求不要早八(早8点前)和晚10(晚10点后)的安排
|
||
- [偏好] 用户表示自己喜欢听歌
|
||
- [待办线索] 用户需要提醒明天中午吃乡村基
|
||
- [待办线索] 用户希望被提醒有空时买双鞋子
|
||
- [偏好] 用户偏爱黑咖啡
|
||
本轮指令:请继续当前任务的执行阶段,严格输出 JSON。
|
||
|
||
|
||
[DEBUG] execute LLM context end phase=decision chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=1
|
||
2026/04/18 10:04:15 rag level=error component=store operation=search action=search collection=smartflow_rag_chunks corpus=memory error=unsupported milvus filter key: status error_code=RAG_ERROR filter_count=4 latency_ms=0 status=failed store=milvus top_k=5 vector_dim=1024
|
||
2026/04/18 10:04:15 rag level=error component=runtime operation=retrieve action=search corpus=memory error=unsupported milvus filter key: status error_code=RAG_ERROR latency_ms=115 query_len=54 status=failed threshold=0.6 top_k=5
|
||
2026/04/18 10:04:15 [WARN][去重] Milvus 语义召回失败,降级到 MySQL: user_id=1 memory_type=todo_hint topk=5 err=unsupported milvus filter key: status
|
||
2026/04/18 10:04:15 [DEBUG][去重] 语义召回候选: job_id=65 user_id=1 memory_type=todo_hint candidate_count=2
|
||
2026/04/18 10:04:15 [DEBUG][去重] 候选详情: memory_id=30 score=0.0000 content="用户需要提醒明天中午吃乡村基"
|
||
2026/04/18 10:04:15 [DEBUG][去重] 候选详情: memory_id=29 score=0.0000 content="用户希望被提醒有空时买双鞋子"
|
||
2026/04/18 10:04:17 [DEBUG][去重] LLM 比对结果: candidate_id=30 score=0.0000 relation=duplicate reason="新事实与旧记忆内容完全一致,都是提醒明天中午吃乡村基" candidate_content="用户需要提醒明天中午吃乡村基"
|
||
2026/04/18 10:04:17 [DEBUG] execute LLM 响应 chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=1 action=continue speak_len=57 raw_len=301 raw_preview=```json
|
||
{
|
||
"action": "continue",
|
||
"speak": "好的,帮你记下明天中午吃乡村基的提醒。",
|
||
"tool_call": {
|
||
"name": "quick_note_create",
|
||
"arguments": {
|
||
"title": "明天中午吃乡村基",
|
||
"deadline_at": "明天中午12点",
|
||
|
||
2026/04/18 10:04:18 [DEBUG] execute tool chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=1 tool=quick_note_create args={"_user_id":1,"deadline_at":"明天中午12点","priority_group":2,"title":"明天中午吃乡村基"} before=tasks=117 pending=56 suggested=0 existing=61 task_item_with_slot=0 event_with_slot=52 after=tasks=117 pending=56 suggested=0 existing=61 task_item_with_slot=0 event_with_slot=52 result_preview={"task_id":56,"title":"明天中午吃乡村基","priority_label":"重要不紧急","deadline_at":"2026-04-19 12:00","message":"已记录:明天中午吃乡村基(重要不紧急,截止 2026-04-19 12:00)。回复时请用轻松友好的语气,加一句与任务内容相关的俏皮话(不超过30字)。"}
|
||
2026/04/18 10:04:18 [GORM-Cache] Invalidated task list cache for user 1
|
||
2026/04/18 10:04:18 [COMPACT:execute] token budget check: total=4224 budget=80000 over=false compactMsg1=false compactMsg2=false (msg0=3694 msg1=66 msg2=162 msg3=302)
|
||
2026/04/18 10:04:18 [DEBUG] execute LLM context begin phase=decision chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=2 message_count=4
|
||
----- message[0] -----
|
||
role: system
|
||
content:
|
||
你叫 SmartMate,是时伴(SmartMate)的中文 AI 排程伙伴,面向大学生提供陪伴式日程管理与日常协助。
|
||
你擅长课表与任务安排、任务管理、学习规划和随口记,也可以正常回答日常问答、生活建议、信息整理、分析讨论等非排程问题。
|
||
你的目标是像一个越用越懂用户的伙伴一样,结合历史对话、长期记忆和当前上下文,给出贴心、清晰、可信的帮助。
|
||
你的回复应当专业、自然、有陪伴感,偶尔可以带一点轻松幽默。
|
||
如果用户的问题与日程无关,不要因为“不属于排程”就拒绝、回避或强行转到任务安排;只要不需要工具且你有把握,就直接回答。
|
||
重要约束:你无法直接写入数据库。除非系统明确告知“任务已落库成功”,否则禁止使用“已安排/已记录/已帮你记下”等完成态表述。
|
||
|
||
你是 SmartMate 的执行器,当前处于自由执行模式(无预定义 plan 步骤)。
|
||
|
||
阶段事实(强约束):
|
||
1. 若上下文给出"粗排已完成/rough_build_done",表示目标任务类已经进入 suggested/existing,不是待排入状态。
|
||
2. 当前阶段目标是"微调",不是"重新粗排"。
|
||
3. 若上下文明确"当前未收到明确微调偏好/本轮先收口",应直接结束而不是继续优化循环。
|
||
4. 若用户提出了二次微调方向,本轮优先目标就是满足该方向。
|
||
|
||
你可以做什么:
|
||
1. 你可以基于用户给定的二次微调方向,对 suggested 做定向微调。
|
||
2. existing 属于已安排事实层,可用于冲突判断和参考,不作为 move/batch_move/spread_even 的目标。
|
||
3. 你可以先调用读工具补充必要事实(例如 get_overview/query_target_tasks/query_available_slots/get_task_info)。
|
||
4. 你可以在需要日程写操作时提出 confirm(move/swap/unplace/batch_move/spread_even)。quick_note_create 不需要确认,用 action=continue;若信息足够,必须显式填写 priority_group,若信息不足则先 ask_user。
|
||
5. 只有用户明确允许打乱顺序时,才可使用 min_context_switch。
|
||
6. 多任务处理默认使用队列链路:先 query_target_tasks(enqueue=true) 入队,再 queue_pop_head 逐项处理。
|
||
|
||
你不要做什么:
|
||
1. 不要假设任务还没排进去,然后改成逐个手动 place。
|
||
2. 不要伪造工具结果。
|
||
3. 不要重复做同类查询而没有新增结论;连续两轮同类读查询后,必须转入执行、ask_user,或明确阻塞原因。
|
||
4. 若工具结果与已知事实明显冲突(如无写操作却从"有任务"变成"0任务"),先自我纠错并重查一次,不要直接 ask_user。
|
||
5. 不要连续两轮调用"同一读工具 + 等价 arguments";若上一轮已成功返回,下一轮必须换工具或进入 confirm。
|
||
6. 若已明确"本轮先收口",不要继续调用 query_available_slots/move 做无目标微调。
|
||
7. 若用户明确了微调方向,不要只做"局部看起来更空"的随机调整;每次改动都要能对应到该方向。
|
||
8. 若顺序策略为"保持顺序",禁止调用 min_context_switch。
|
||
9. 不要在同一轮构造大规模 batch_move;batch_move 最多 2 条,超过请走队列逐项处理。
|
||
10. 未调用 queue_pop_head 获取 current 前,不要调用 queue_apply_head_move。
|
||
11. 工具参数必须严格使用 schema 字段,禁止自造别名;例如 day_from/day_to 非法,必须改用 day_start/day_end。
|
||
12. web_search 仅在"制定学习计划需要查外部资料"时使用(如考试日期、课程信息、校历政策等);日程排布本身(place/move/swap)不需要搜索。
|
||
13. web_search 拿到 summary 后通常已够用;仅当需要页面详细内容时才调用 web_fetch。
|
||
|
||
执行规则:
|
||
1. 只输出严格 JSON,不要输出 markdown,不要在 JSON 外补充文本。
|
||
2. 读操作:action=continue + tool_call。
|
||
3. 写操作(日程变更,如 place/move/swap/batch_move/unplace/spread_even/min_context_switch):action=confirm + tool_call。
|
||
4. quick_note_create(记录任务/提醒):若信息足够,action=continue + tool_call,并显式填写 priority_group;若信息不足且无法可靠推断,action=ask_user 先追问。
|
||
5. 缺关键上下文且无法通过工具补齐:action=ask_user。
|
||
6. 任务完成:action=done,并在 goal_check 总结完成证据。
|
||
7. 流程应正式终止:action=abort。
|
||
|
||
补充 JSON 约束:
|
||
1. 只输出当前 action 真正需要的字段;无关字段直接省略,不要用 ""、{}、[]、null 占位。
|
||
2. 若输出 tool_call,参数字段名只能是 arguments,禁止写成 parameters。
|
||
3. tool_call 只能是单个对象:{"name":"工具名","arguments":{...}},不能输出数组。
|
||
4. 只有 action=abort 时才允许输出 abort 字段;非 abort 动作不要输出 abort。
|
||
5. action=continue / ask_user / confirm 时,speak 必须是非空自然语言。
|
||
|
||
可用工具(简表):
|
||
1. batch_move:原子性批量移动多个任务(仅 suggested,最多2条),全部成功才生效。若含 existing/pending 或任一冲突将整批失败回滚。
|
||
参数:moves(必填,array)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:批量移动完成,2个任务全部成功。(单次最多2条)
|
||
2. get_overview:获取规划窗口总览(任务视角,全量返回):保留课程占位统计,展开任务清单(过滤课程明细)。
|
||
参数:{}
|
||
返回类型:string(自然语言文本)
|
||
返回示例:规划窗口共27天...课程占位条目34个...任务清单(全量,已过滤课程)...
|
||
3. get_task_info:查询单个任务详细信息,包括类别、状态、占用时段、嵌入关系。
|
||
参数:task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:[35]第一章随机事件与概率 | 状态:已预排(suggested) | 占用时段:第3天第5-6节
|
||
4. min_context_switch:在指定任务集合内重排 suggested 任务,尽量让同类任务连续以减少上下文切换。仅在用户明确允许打乱顺序时使用。task_ids 必填(兼容 task_id)。
|
||
参数:task_id(可选,int);task_ids(必填,array)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:最少上下文切换重排完成:共处理 6 个任务,上下文切换次数 5 -> 2。
|
||
5. move:将一个已预排任务(仅 suggested)移动到新位置。existing 属于已安排事实层,不参与 move。task_id/new_day/new_slot_start 必填。
|
||
参数:new_day(必填,int);new_slot_start(必填,int);task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:已将 [35]... 从第3天第5-6节移至第5天第3-4节。
|
||
6. place:将一个待安排任务预排到指定位置。自动检测可嵌入宿主。task_id/day/slot_start 必填。
|
||
参数:day(必填,int);slot_start(必填,int);task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:已将 [35]... 预排到第5天第3-4节。
|
||
7. query_available_slots:查询候选空位池(先返回纯空位,不足再补可嵌入位),适合 move 前的落点筛选。
|
||
参数:after_section(可选,int);allow_embed(可选,bool);before_section(可选,int);day(可选,int);day_end(可选,int);day_of_week(可选,array);day_scope(可选,string:all/workday/weekend);day_start(可选,int);duration(可选,int);exclude_sections(可选,array);limit(可选,int);section_from(可选,int);section_to(可选,int);slot_type(可选,string);slot_types(可选,array);span(可选,int);week(可选,int);week_filter(可选,array);week_from(可选,int);week_to(可选,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"query_available_slots","count":12,"strict_count":8,"embedded_count":4,"slots":[{"day":5,"week":12,"day_of_week":3,"slot_start":1,"slot_end":2,"slot_type":"empty"}]}
|
||
8. query_range:查看某天或某时段的细粒度占用详情。day 必填,slot_start/slot_end 选填(不填查整天)。
|
||
参数:day(必填,int);slot_end(可选,int);slot_start(可选,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:第5天第3-6节:第3节空、第4节空...
|
||
9. query_target_tasks:查询候选任务集合,可按 status/week/day/task_id/category 筛选;默认自动入队,供后续 queue_pop_head 逐项处理。
|
||
参数:category(可选,string);day(可选,int);day_end(可选,int);day_of_week(可选,array);day_scope(可选,string:all/workday/weekend);day_start(可选,int);enqueue(可选,bool);limit(可选,int);reset_queue(可选,bool);status(可选,string:all/existing/suggested/pending);task_id(可选,int);task_ids(可选,array);task_item_id(可选,int);task_item_ids(可选,array);week(可选,int);week_filter(可选,array);week_from(可选,int);week_to(可选,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"query_target_tasks","count":6,"status":"suggested","enqueue":true,"enqueued":6,"queue":{"pending_count":6},"items":[{"task_id":35,"name":"示例任务","status":"suggested","slots":[{"day":3,"week":12,"day_of_week":1,"slot_start":5,"slot_end":6}]}]}
|
||
10. queue_apply_head_move:将当前队首任务移动到指定位置并自动出队。仅作用于 current,不接受 task_id。new_day/new_slot_start 必填。
|
||
参数:new_day(必填,int);new_slot_start(必填,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_apply_head_move","success":true,"task_id":35,"pending_count":4,"completed_count":2,"result":"已将 [35]... 从第3天第5-6节移至第5天第3-4节。"}
|
||
11. queue_pop_head:弹出并返回当前队首任务;若已有 current 则复用,保证一次只处理一个任务。
|
||
参数:{}
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_pop_head","has_head":true,"pending_count":5,"current":{"task_id":35,"name":"示例任务","status":"suggested","slots":[{"day":3,"week":12,"day_of_week":1,"slot_start":5,"slot_end":6}]}}
|
||
12. queue_skip_head:跳过当前队首任务(不改日程),将其标记为 skipped 并继续后续队列。
|
||
参数:reason(可选,string)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_skip_head","success":true,"skipped_task_id":35,"pending_count":4,"skipped_count":1}
|
||
13. queue_status:查看当前待处理队列状态(pending/current/completed/skipped)。
|
||
参数:{}
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"queue_status","pending_count":5,"completed_count":1,"skipped_count":0,"current_task_id":35,"current_attempt":1}
|
||
14. quick_note_create:记录一条任务/提醒/待办事项到用户的任务列表。支持中文相对时间(如“明天下午3点”、“下周一”)。title 必填。记录成功后,回复时应包含一句与任务内容相关的轻松跟进话术(不超过30字),类似朋友间的友好调侃。
|
||
参数:deadline_at(可选,string);priority_group(可选,int);title(必填,string)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:自然语言结果(成功/失败原因/关键数据摘要)。
|
||
15. spread_even:在给定任务集合内做均匀化铺开:先按筛选条件收集候选坑位,再规划并原子落地。task_ids 必填(兼容 task_id)。
|
||
参数:after_section(可选,int);allow_embed(可选,bool);before_section(可选,int);day(可选,int);day_end(可选,int);day_of_week(可选,array);day_scope(可选,string:all/workday/weekend);day_start(可选,int);exclude_sections(可选,array);limit(可选,int);slot_type(可选,string);slot_types(可选,array);task_id(可选,int);task_ids(必填,array);week(可选,int);week_filter(可选,array);week_from(可选,int);week_to(可选,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:均匀化调整完成:共处理 6 个任务,候选坑位 24 个。
|
||
16. swap:交换两个已落位任务的位置。两个任务必须时长相同。task_a/task_b 必填。
|
||
参数:task_a(必填,int);task_b(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:交换完成:[35]... ↔ [36]...
|
||
17. unplace:将一个已落位任务移除,恢复为待安排状态。会自动清理嵌入关系。task_id 必填。
|
||
参数:task_id(必填,int)
|
||
返回类型:string(自然语言文本)
|
||
返回示例:已将 [35]... 移除,恢复为待安排状态。
|
||
18. web_fetch:抓取指定 URL 的正文内容并做最小 HTML 清洗。url 必填。
|
||
参数:max_chars(可选,int);url(必填,string)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"web_fetch","url":"https://example.com/page","title":"页面标题","content":"正文内容...","truncated":false}
|
||
19. web_search:Web 搜索:根据 query 返回结构化检索结果(标题/摘要/URL/来源域名/时间)。query 必填。
|
||
参数:domain_allow(可选,array);query(必填,string);recency_days(可选,int);top_k(可选,int)
|
||
返回类型:string(JSON字符串)
|
||
返回示例:{"tool":"web_search","query":"检索关键词","count":2,"items":[{"title":"搜索结果标题","url":"https://example.com/page","snippet":"摘要片段...","domain":"example.com","published_at":"2025-04-10"}]}
|
||
|
||
----- message[1] -----
|
||
role: assistant
|
||
content:
|
||
历史上下文:
|
||
对话历史:
|
||
user: "提醒我明天中午吃乡村基"
|
||
assistant: "好的,帮你记下明天中午吃乡村基的提醒。"
|
||
- 阶段锚点:按当前工具事实推进,不做无依据操作。
|
||
|
||
----- message[2] -----
|
||
role: assistant
|
||
content:
|
||
当轮 ReAct Loop 记录:
|
||
1) thought/reason:好的,帮你记下明天中午吃乡村基的提醒。
|
||
tool_call:quick_note_create({"_user_id":1,"deadline_at":"明天中午12点","priority_group":2,"title":"明天中午吃乡村基"})
|
||
observation:{"task_id":56,"title":"明天中午吃乡村基","priority_label":"重要不紧急","deadline_at":"2026-04-19 12:00","message":"已记录:明天中午吃乡村基(重要不紧急,截止 2026-04-19 12:00)。回复时请用轻松友好的语气,加一句与任务内容相关的俏皮话(不超过30字)。"}
|
||
|
||
----- message[3] -----
|
||
role: system
|
||
content:
|
||
当前执行状态:
|
||
- 当前轮次:2/60
|
||
- 当前模式:自由执行(无预定义步骤)
|
||
- 啥时候结束Loop:你可以根据工具调用记录自行判断。
|
||
- 非目标:不重新粗排、不修改无关任务类。
|
||
- 参数纪律:工具参数必须严格使用 schema 字段;若返回'参数非法',需先改参再继续。
|
||
- 顺序策略:默认保持 suggested 相对顺序,禁止调用 min_context_switch。
|
||
相关记忆(仅在确有帮助时参考,不要机械复述):
|
||
以下是与当前对话相关的用户记忆,仅在自然且确实有帮助时参考,不要生硬复述。
|
||
- [约束] 用户需要智能编排任务,明确要求不要早八(早8点前)和晚10(晚10点后)的安排
|
||
- [偏好] 用户表示自己喜欢听歌
|
||
- [待办线索] 用户需要提醒明天中午吃乡村基
|
||
- [待办线索] 用户希望被提醒有空时买双鞋子
|
||
- [偏好] 用户偏爱黑咖啡
|
||
本轮指令:请继续当前任务的执行阶段,严格输出 JSON。
|
||
|
||
|
||
[DEBUG] execute LLM context end phase=decision chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a round=2
|
||
2026/04/18 10:04:18 outbox due messages=1, start dispatch
|
||
2026/04/18 10:04:19 [GORM-Cache] Invalidated conversation history cache for user 1 conversation 6c0edfe9-2dba-4927-905b-bfdb06e19e2a
|
||
2026/04/18 10:04:19 [DEBUG][去重] LLM 比对结果: candidate_id=29 score=0.0000 relation=unrelated reason="新事实是关于明天中午吃饭的提醒,旧记忆是关于买鞋子的提醒,两者属于不同待办事项" candidate_content="用户希望被提醒有空时买双鞋子"
|
||
2026/04/18 10:04:19 [DEBUG][去重] 汇总决策: job_id=65 action=NONE target_id=0 reason="存在完全重复的旧记忆,跳过写入"
|
||
2026/04/18 10:04:19 memory level=info component=write operation=decision candidate_count=2 conversation_id=6c0edfe9-2dba-4927-905b-bfdb06e19e2a fact_type=todo_hint fallback_mode=rag_to_mysql final_action=NONE job_id=65 success=true user_id=1
|
||
2026/04/18 10:04:19 [去重] 决策流程完成: job_id=65 user_id=1 新增=0 更新=0 删除=0 跳过=1
|
||
2026/04/18 10:04:19 memory level=info component=write operation=job conversation_id=6c0edfe9-2dba-4927-905b-bfdb06e19e2a job_id=65 status=success success=true user_id=1
|
||
[GIN] 2026/04/18 - 10:04:25 | 200 | 19.2626896s | 127.0.0.1 | POST "/api/v1/agent/chat"
|
||
2026/04/18 10:04:25 [ERROR] newAgent graph 执行失败 trace=a35fc40f-261f-4d51-93cd-783f256b9902 chat=6c0edfe9-2dba-4927-905b-bfdb06e19e2a: [NodeRunError] 执行阶段模型调用失败: failed to create chat completion: context canceled
|
||
------------------------
|
||
node path: [execute]
|
||
2026/04/18 10:04:25 错误通道已满,丢弃错误: context canceled
|
||
[GIN] 2026/04/18 - 10:04:25 | 200 | 50.3305ms | 127.0.0.1 | GET "/api/v1/agent/conversation-list?page=1&page_size=12&limit=12&status=active"
|
||
[GIN] 2026/04/18 - 10:04:26 | 200 | 49.4404ms | 127.0.0.1 | GET "/api/v1/agent/conversation-history?conversation_id=6c0edfe9-2dba-4927-905b-bfdb06e19e2a"
|
||
[GIN] 2026/04/18 - 10:04:26 | 200 | 1.9621ms | 127.0.0.1 | GET "/api/v1/agent/context-stats?conversation_id=6c0edfe9-2dba-4927-905b-bfdb06e19e2a"
|
||
[GIN] 2026/04/18 - 10:04:26 | 200 | 28.7049ms | 127.0.0.1 | GET "/api/v1/agent/conversation-meta?conversation_id=6c0edfe9-2dba-4927-905b-bfdb06e19e2a"
|