deepseek/招子乐#37
Open
zhaozile0101 wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
完成能力点
后端工程能力
Agent 项目经验
RAG / 知识库能力
业务系统集成
安全与权限意识
管理后台 / 产品意识
设计说明
一、整体架构
系统采用分层解耦设计,从上到下分为:
数据流向:
用户请求 → API 创建任务和运行记录 → 后台任务执行 Worker → Worker 调用 Planner 获取计划 → Worker 调用 Executor 执行 → Executor 依次调用各工具 → 工具从 fixtures/数据库读取数据 → Executor 汇总结果和事件 → Worker 将结果和事件写入数据库 → 用户轮询 API 获取结果。
二、状态流转
任务(tasks 表)状态:
运行(runs 表)状态:
事件(run_events 表)顺序:
每个工具调用前后都会记录一个 tool.call 事件,包含 seq(单调递增序号)、type、tool_name、payload(含 status、output_summary 或 error)、created_at。
三、工具调用边界
工具分为只读工具和写工具两类:
调用顺序固定为上述顺序,由 Planner 保证。写工具若因权限不足被跳过,Executor 会记录 skipped 事件,且最终结果中 approval_draft_id 为 None,recommended_action 为 "analysis_only"。
四、RAG 策略
知识库数据存储在 knowledge_chunks 表中,包含以下字段:
检索步骤:
五、权限设计
权限数据源:users 表的 permissions_json 字段,存储 JSON 数组,例如 ["tasks:create", "oa:approval:write"]。
API 级权限(通过 require_permissions 依赖实现):
工具级权限(在 Executor 中检查):
权限拒绝处理:
审计日志记录每次权限决策(decision = "allow" 或 "deny")。
六、脱敏策略
敏感字段黑名单:vendor_secret、unit_cost_usd、contract_detail、debug、candidate_note。
脱敏函数 sanitize_result 递归遍历字典和列表,移除键名在黑名单中的字段。应用于:
本地验证
执行以下命令并全部通过: