feat: T-04 Core RO Tool 节点——chat Tool 接入+归属校验+agent_tool_call 落库
- app/tool/core_tools.py: 三只读 Tool(query_customer_profile/holdings/recent_trades, Core RO 仅 SELECT) + TOOL_REGISTRY 白名单(requires_customer); JSON 安全化(Decimal 两位/时间 isoformat) - app/service/tool_service.py: match_intent 关键词意图(仅 customer/advisor; risk/analyst 空转归 C1/C2) + assert_tool_access 归属断言(customer 本人/advisor assigned/risk_officer 全量/其余拒, 口径对齐 deps.assert_customer_access) + run_tool 编排(白名单→校验→执行→agent_tool_call 落库, 落库失败降级 warning) - agent_service: 图 START→tool→llm→guard; Tool 结果注入 LLM 上下文(SystemMessage); 降级回复带 Tool 摘要; chat() 可选 session 上下文(缺省空转, T-07 兼容) - session_repository: insert_tool_call(message_id 一期 NULL, session_id+trace_id 可还原) - 归属拒绝口径: Tool 层不抛 403 改 blocked 留痕(AUTH_403_* 同码), 对话内呈现——API 层 deny 铁律不变 - tests: test_chat_tools 20 例(三态+落库字段+降级+图注入) + test_chat 4 例(全链路/JWT 外 debug 通道), _ddl 补 agent_tool_call/core_holding, 297 绿 - 真库冒烟: uvicorn+真 MySQL/Redis chat 触发持仓查询 success 落痕 47ms, 现场已清理
This commit is contained in:
@@ -39,9 +39,9 @@
|
||||
| 代理人助手 Agent | L2 画像、RAG、草稿 | L1 只读、Milvus | 空壳 service(chat 骨架已通) |
|
||||
| 数据分析 Agent | NL→SQL→解读 | Core RO、画像只读 | 空壳 service(chat 骨架已通) |
|
||||
| 风控监测 Agent | 预警、L3、R-02 适当性 | 交易事件、AML 名单 | **已实现**(B1~B7:rules/alert_service/profile_l3/aml_service/engine/scoring 占位 + 4 API + suitability + main 集成与挂账①~⑦) |
|
||||
| Core 只读层 | L0 事实查询 | `jinrong_core` | **core_ro.py 已实现**(含风控扩展查询) |
|
||||
| 共用底座 | 会话、审计、输入防护 | MySQL 11 表 + Redis | **大部分接入(2026-09-07)**:会话(T-06 session_repository + memory_service 窗口)、审计中间件(T-02 http_access + input_guard_log 双写)已接;输入防护规则待 T-03 |
|
||||
| 对话编排 | LangGraph StateGraph + DeepSeek | langgraph/langchain-openai | **骨架已实现(T-07,2026-09-07)**:llm→guard(免责声明);Tool 节点待 T-04/阶段 C |
|
||||
| Core 只读层 | L0 事实查询 | `jinrong_core` | **已实现 + 已接对话 Tool(T-04)**:core_ro 经 app/tool/core_tools.py 三只读 Tool(L0/持仓/流水)进 chat;风控扩展查询照旧 |
|
||||
| 共用底座 | 会话、审计、输入防护 | MySQL 11 表 + Redis | **大部分接入(2026-09-07)**:会话(T-06 session_repository + memory_service 窗口)、审计中间件(T-02 http_access + input_guard_log 双写)、agent_tool_call Tool 留痕(T-04)已接;输入防护规则待 T-03 |
|
||||
| 对话编排 | LangGraph StateGraph + DeepSeek | langgraph/langchain-openai | **已实现(T-07 骨架 + T-04 Tool 节点,2026-09-07)**:tool(关键词意图→Tool)→llm→guard(免责声明);LLM intent 与风控四 Tool 归 C1/C2 |
|
||||
| 同步脚本 | 归属、Neo4j | Core → agent / 图库 | **sync_*.py 已实现** |
|
||||
|
||||
------
|
||||
@@ -51,11 +51,13 @@
|
||||
```text
|
||||
api/ → risk / simulate / chat / deps / audit_middleware 已实现;knowledge、admin 空壳 【大部分】
|
||||
service/ → risk/*(rules/alert/aml/engine/l3/scoring/locks/redis_gateway)+ suitability +
|
||||
auth_service(T-01 JWT)+ agent_service(T-07 StateGraph)+ memory_service(T-06)已实现;
|
||||
auth_service(T-01 JWT)+ agent_service(T-07 图 + T-04 tool 节点)+ memory_service(T-06)+
|
||||
tool_service(T-04 对话 Tool 编排:意图/归属校验/run_tool 落库)已实现;
|
||||
rag_service 空壳 【大部分】
|
||||
tool/ → document_parser、embedding_tool、milvus_tool 【空壳】
|
||||
tool/ → core_tools(T-04:L0/持仓/流水只读 Tool + TOOL_REGISTRY 白名单)已实现;
|
||||
document_parser、embedding_tool、milvus_tool 【部分;RAG 三件空壳】
|
||||
repository/ → core_ro(Core 只读)+ risk_repository(风控四表+审计双写)+
|
||||
session_repository(agent_session/agent_message,T-06) 【已实现】
|
||||
session_repository(agent_session/agent_message/agent_tool_call,T-06/T-04) 【已实现】
|
||||
gateway/ → 模拟交易网关(trade_gateway + gateway_repository 仅 INSERT core_trade) 【已实现 B5】
|
||||
model/ → schemas(Pydantic)、entities(ORM) 【占位】(风控暂用 dict,收敛待后续)
|
||||
config/ → settings(双库 + risk_* 阈值 + JWT 配置)、database 【settings 已实现】
|
||||
|
||||
Reference in New Issue
Block a user