Version: 0.5.6.dev.260314

 feat(agent): 重构 Agent 分层并修复普通聊天助手消息未写入 Redis 的问题

🔧 按职责重构 backend/agent 目录为 route/chat/quicknote 三层结构

🔄 将随口记链路拆分为 graph/nodes/tool/state/prompt,其中 graph 仅负责连线

🏃 新增 quicknote runner(方法引用)来收口节点依赖,提升代码可读性

🔀 将控制码分流逻辑抽离到 agent/route,服务层改为薄封装调用

📚 更新相关 README 与测试引用路径,保持原业务逻辑不变

🐛 修复普通聊天链路遗漏 assistant 写入 Redis 的问题(确保 MySQL 和 Redis 的口径一致)
This commit is contained in:
Losita
2026-03-14 19:42:26 +08:00
parent 21d6fe5b5f
commit c689af56c8
16 changed files with 1018 additions and 962 deletions

View File

@@ -0,0 +1,36 @@
package quicknote
import "testing"
func TestDeriveQuickNoteTitleFromInput(t *testing.T) {
cases := []struct {
name string
input string
want string
}{
{
name: "保留核心事项并去掉尾部提醒口头语",
input: "明天上午12点我要去取快递到时候记得q我",
want: "明天上午12点我要去取快递",
},
{
name: "去掉常见前缀口头语",
input: "提醒我周五下午三点交实验报告",
want: "周五下午三点交实验报告",
},
{
name: "空输入兜底",
input: " ",
want: "这条任务",
},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := deriveQuickNoteTitleFromInput(tc.input)
if got != tc.want {
t.Fatalf("title 提取不符合预期got=%q want=%q", got, tc.want)
}
})
}
}