4928ffc0f7
会话历史(Redis,易失,与长期画像分开)经 MCP 工具进出 Eino 图:
recall 召回历史填 MessagesPlaceholder,写回把本轮 user/assistant 落历史。
- mcp-go: internal/history(go-redis, sundynix:history:<session>, LPUSH+LTRIM 保留近20条,
24h TTL) + 工具 history_get(返回JSON turns)/history_append; main 开 Redis(降级)
- dispatcher Eino: 模板加 MessagesPlaceholder('history'); recall 调 history_get→转 schema.Message;
Handle 累积 answer; memorize 异步 history_append(user+assistant)
- shared: contract.MetaSessionID; gateway: SubmitTask 注入 Meta[session_id](X-Session-ID 头,缺省 default)
- demo.sh: 同会话两轮提交,验证第2轮召回第1轮历史
- 验证: 4 模块 build✓ + 3 e2e PASS; live 跑通——轮1=0轮历史→落库, 轮2 history_get 命中→注入
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
12 lines
502 B
Go
12 lines
502 B
Go
package eino
|
|
|
|
// AgentState 是 Eino 图的全局状态,贯穿 recall→prompt→model 各节点。
|
|
// 偏好记忆经 recall 节点写入,供模板注入与写回抽取使用。
|
|
type AgentState struct {
|
|
UserID string // 来自 Task.Meta["user_id"]
|
|
SessionID string // 来自 Task.Meta["session_id"]
|
|
Profile string // 召回到的常驻画像(always-on 偏好记忆)
|
|
Input string // 本次输入(DSL 原文)
|
|
Answer string // 累积输出,供写回阶段抽取新记忆
|
|
}
|