Files
group_xinghuo_jinrong/docs/项目框架设计/表设计/05-多Agent共用底座清单.md
T
zhanghongyu_0626 1ddd44a6cb Add core database support and enhance documentation
- Introduced `MYSQL_CORE_DATABASE` in `.env.example` and `settings.py` for core database configuration.
- Added `CoreReadOnlyRepository` for read-only access to the `jinrong_core` database.
- Updated `AGENTS.md`, `README.md`, and various documentation files to reflect new agent onboarding processes and project structure.
- Revised requirements in `requirements.txt` to include `langgraph` and `langchain-core`.
- Enhanced `FLOW.md` with local bootstrap instructions for setting up the core simulation environment.
- Added new scripts for database creation and seeding for the core simulation library.
- Improved overall documentation for clarity on project architecture and memory management.
- Updated `TODO.md` to reflect current development priorities and tasks.
2026-09-05 17:39:16 +08:00

9.8 KiB
Raw Blame History

多 Agent 共用底座清单(先建这个)

用途:按「哪些东西必须多 Agent 一起用」划分,方便 一次性把底座搭好,再让四个组并行开发各自 Agent。
不是按工程上线顺序(Wave 0/1/2)划分。


一、怎么读这份清单

每张表 / 每个存储项都标了 几个 Agent 会用到,分三档:

档位 含义 你要做什么
🔴 全员共用 4 个 Agent 都要 读或写 底座第一批必建
🟡 跨 Agent 交换 2~3 个 Agent 之间 传数据 底座第二批必建(不建则联调卡住)
⚪ 单 Agent 专用 mainly 1 个 Agent 自己写自己用 各组自己建,不算公共底座

L0(原有业务系统):不算 Agent 库里的表,但底座要留 只读接口(查持仓、正式 C1~C5),四个 Agent 都要接。


二、总览:先建什么、后建什么

【第一批 · 全员底座】MySQL 6 张 + Redis 会话/限流 + Core 只读接口
         │
【第二批 · 跨 Agent 交换】MySQL 5 张 + Redis 画像缓存 + Milvus 1 库 + Neo4j 图
         │
【第三批 · 各 Agent 专用】MySQL 5 张 + Milvus 1 库(仅代理人) + Redis 代理人快照
         │
    四个 Agent 并行开发
批次 MySQL Redis Milvus Neo4j
第一批 6 张 2 类 Key — —
第二批 5 张 3 类 Key 1 个 Collection 整图 P0
第三批 5 张 1 类 Key 1 个 Collection —
合计 16 张 6 类 2 个 1 套

三、MySQL:完整对照表

🔴 第一批 — 全员共用(6 张)

四个 Agent 任意一个 要跑起来,这 6 张都必须有。
SQL 文件:01-mysql-共用底座.sql 前半部分

表名 几个 Agent 用 谁写 谁读 干什么
agent_session 4 四个都写 四个都读 一次对话会话
agent_message 4 四个都写 四个都读 每条聊天永久存档
agent_tool_call 4 四个都写 四个都读 调了哪些查数/检索接口
audit_log 4 + 合规 四个都写 合规巡检读 审计总账,只增不改
input_guard_log 4 平台/四个都写 安全/合规 恶意输入拦截记录
customer_advisor_rel 4 平台同步 Core 四个都读 客户归哪个代理人管(权限)

🟡 第二批 — 跨 Agent 交换(5 张)

多个 Agent 靠这些表传数据;并行开发前必须建好,否则互相读不到。
SQL 文件:01-mysql-共用底座.sql 后半部分

表名 几个 Agent 用 谁写 谁读 交换什么
customer_profile_l1 4 客户 Agent 客户、代理人、风控、分析 客户侧偏好:风格、规划、阈值偏好
customer_profile_l2 3 代理人 Agent 代理人、风控、分析 服务侧记录:诉求、待办、服务标签
customer_profile_l3 4 风控 Agent 客户(只读)、代理人、分析 监测标签:正常/关注/高风险
risk_alert 2~3 风控 Agent 风控、分析、合规 预警单;分析统计「还有多少没审」
risk_suitability_log 3 风控 Agent 客户、代理人、交易钩子 买的产品是否匹配;可否拦截购买

⚪ 第三批 — 单 Agent 专用(5 张,各组自建)

不算公共底座;对应组开发自己的 Agent 时再建即可。
SQL 文件:02-mysql-agent专用.sql

表名 主要使用者 干什么 为何不算共用
customer_threshold_config 仅客户 Agent 客户设「亏 10% 提醒我」 只有客户 Agent 写;阈值偏好摘要也会进 L1
customer_notify_log 仅客户 Agent 提醒发送留痕 只有客户 Agent 写
advisor_draft 仅代理人 Agent 话术/跟进草稿 只有代理人用,不外泄给其他 Agent
compliance_hit_log 仅代理人 Agent 违规话术检测 主要服务代理人合规
analytics_query_log 仅分析 Agent 人话查数 SQL 留痕 只有分析 Agent 写

四、Redis:完整对照表

🔴 第一批 — 全员共用

Key 模式 几个 Agent 用 干什么
sess:{agent}:{session_id}:ctx 4 当前对话上下文(意图、槽位)
sess:{agent}:{session_id}:msgs 4 最近 ~20 轮消息滑动窗口
sess:{agent}:{session_id}:lock 4 防并发写乱会话
guard:rate:{actor_id}:{agent} 4 限流
guard:block:{actor_id} 4 临时封禁

🟡 第二批 — 跨 Agent 交换

Key 模式 几个 Agent 用 谁写 谁读
profile:l1:{customer_id} 4 客户 Agent 代理人、风控、分析
profile:l2:{customer_id}:{advisor_id} 3 代理人 Agent 代理人、风控、分析
profile:l3:{customer_id} 4 风控 Agent 客户、代理人、分析
risk:pub:alert 2+ 风控 Agent 风控工作台(Pub/Sub 推送)

⚪ 第三批 — 单 Agent

Key 模式 主要使用者 说明
cache:advisor:snapshot:{advisor_id}:{customer_id} 代理人 Agent A-01 资产概况缓存;权威副本在 L2 表
risk:dedup:{customer_id}:{rule_id}:{date} 风控 Agent 内部防重复预警,别的 Agent 不读

五、Milvus:完整对照表

Collection 档位 几个 Agent 用 干什么
kb_product_rules 🟡 共用 客户 + 代理人 搜基金产品手册、交易规则(都要溯源)
kb_business_ops ⚪ 专用 仅代理人 内部办事流程(定投、赎回到账等)

底座建议:先建 kb_product_rules 并导入产品文档;kb_business_ops 等代理人组开发时再建。


六、Neo4j:完整对照表

内容 档位 几个 Agent 用 干什么
整套 P0 图(Customer/Product/Advisor/RiskGrade + HOLDS 等关系) 🟡 共用 4 查「客户持有啥」「产品要什么风险等级」「归哪个代理人」

底座建议:第二批与 MySQL 画像表一起建;数据从 Core 同步,Agent 不往 Neo4j 写画像。


七、Core 只读接口(无表,但底座必接)

数据 几个 Agent 用 说明
正式客户信息、C1~C5 风险等级 4 L0,Agent 库 不建表
持仓、流水、交易 4 事实金额以 Core 为准
行情/净值 主要客户 Agent 其他 Agent 按需

八、搭建顺序检查表(复制即用)

第一批:全员底座(Day 1)

  • MySQL:agent_session / agent_message / agent_tool_call / audit_log / input_guard_log / customer_advisor_rel
  • Redis:sess:*、guard:*
  • 平台 SDK:SessionService、AuditService、RBAC 校验(见 02-JWT-RBAC鉴权手册.md)
  • Core 只读 API 联调通过

第二批:跨 Agent 交换(Day 2~3)

  • MySQL:customer_profile_l1 / l2 / l3 / risk_alert / risk_suitability_log
  • Redis:profile:l1/l2/l3、risk:pub:alert
  • Milvus:kb_product_rules + 首批产品文档入库
  • Neo4j:P0 节点关系 + Core 同步 Job

第三批:各 Agent 专用(各组并行时自建)

  • 客户组:customer_threshold_config、customer_notify_log
  • 代理人组:advisor_draft、compliance_hit_log + Milvus kb_business_ops
  • 分析组:analytics_query_log
  • 风控组:risk:dedup(可选,内部优化)

九、一张矩阵:16 张 MySQL 表 × 4 个 Agent

图例:W=写入 R=读取 ·=不用

表名 客户 代理人 分析 风控 档位
agent_session W/R W/R W/R W/R 🔴
agent_message W/R W/R W/R W/R 🔴
agent_tool_call W/R W/R W/R W/R 🔴
audit_log W W W W 🔴
input_guard_log W W W W 🔴
customer_advisor_rel R R R R 🔴
customer_profile_l1 W/R R R R 🟡
customer_profile_l2 · W/R R R 🟡
customer_profile_l3 R R R W 🟡
risk_alert · · R W 🟡
risk_suitability_log R R · W 🟡
customer_threshold_config W/R · · · ⚪
customer_notify_log W · · · ⚪
advisor_draft · W/R · · ⚪
compliance_hit_log · W · · ⚪
analytics_query_log · · W · ⚪

底座 = 上表所有 🔴 + 🟡 行 = MySQL 11 张表


十、SQL 文件怎么用

文件 内容 何时执行
01-mysql-共用底座.sql 🔴6 + 🟡5 = 11 张 并行开发前统一执行
02-mysql-agent专用.sql ⚪ 5 张 各 Agent 组开发时执行(或一次性全建)

十一、和总览文档的关系