Files
common_agent/设计文档/5.Agent会话模块设计.md

51 lines
1.2 KiB
Markdown
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.
# Agent 会话模块设计
## 1. 核心模型
| 对象 | 说明 |
|------|------|
| Agent 定义 | Agent 配置主数据 |
| Agent 会话 | 一段连续对话上下文 |
| Agent 消息 | 会话中的单条消息 |
| 能力绑定 | Agent 或 Workflow 绑定知识库、MCP、Skill 等能力 |
## 2. 对话模式
- 普通对话:直接根据会话消息调用 Chat 模型。
- RAG 对话:先向量化问题,再召回知识切片,再组装上下文调用 Chat 模型。
- Workflow 对话:通过绑定的 Workflow 运行,消息与运行记录互相关联。
## 3. 引用设计
`agent_message.citation_json` 保存回答引用:
- 文档 ID。
- 切片 ID。
- 分数。
- 引用文本摘要。
- 知识库 ID。
引用只保存必要摘要,完整切片仍以 `rag_chunk` 为准。
## 4. 状态设计
会话状态建议包括:
- ACTIVE活跃。
- CLOSED已关闭。
- FAILED异常终止。
消息角色建议包括:
- USER。
- ASSISTANT。
- SYSTEM。
- TOOL。
## 5. 模块依赖
- 依赖知识资产模块完成 RAG 召回。
- 依赖模型与路由模块完成 Chat 调用。
- 可依赖 Workflow 模块执行复杂流程。
- 运行观测模块读取会话关联的运行记录。