feat(dingtalk): stream AI trace cards and unify trace streaming - #226
feat(dingtalk): stream AI trace cards and unify trace streaming#226skywclouds wants to merge 14 commits into
Conversation
Introduce a shared trace_streamer that drives AI trace cards for both Feishu and DingTalk, replacing the Feishu-only inline implementation. Add DingTalk interactive card create-and-deliver plus streaming output with flowStatus states, and thread the trace into service intake. Refactor the Feishu streamer onto the shared core and add focused regression tests for the DingTalk streamer and channel trace cards.
|
新增提交: 背景:数字员工 SOP 编辑器(源码 / 流程图视图)的转人工节点带有一个「处理人」下拉框,实际使用中用户经常不配置或错误配置,导致转人工落到错误的回退对象。 改动:
回滚:把前后端两个开关改回 测试:后端 2052 passed / 前端 244 passed / ruff 无新增问题 / vite build 通过。依赖旧优先级的测试改为 monkeypatch 打开回滚开关验证回滚路径,另新增 4 个现行方案测试。 |
渠道 handoff_notice 与网页收件箱卡片共用 core.handoff_notice 构建: 标题(SOP·节点)、提问人、未配置处理人说明、SOP 入口到转人工的对话 窗口。渠道通知头部补上未配置处理人时的实际转接对象(与用户侧回复 同源),网页 /api/chat/handoffs 暴露统一 notice 内容,收件箱卡片 改为渲染该内容,旧字段回退保留。
purge_chat_session_records 是所有会话删除路径(用户删会话/删员工/ 删团队/启动孤儿清扫)的汇聚点,在此级联取消该会话的 pending 转人工 请求,避免原会话删除后残留记录一直挂在收件箱里。仅取消 pending, 历史状态保留审计,取消原因写入 metadata_json.cancelled_reason。
|
新增提交: 背景:客户反馈转人工时渠道端(飞书/企微)与网页端"待回答"收件箱的内容不一致:网页端有「由于没有配置处理人,已经转接给Administrator」提示,渠道端没有;且渠道端通知内容此前问题较多——slot 英文键原样输出(与用户原话三重复)、上下文仅回看 2 条、多处截断不一致(240/300/600/800)。 改动一:统一通知生成(
改动二:会话删除级联取消(
测试:后端全量 2059 passed(新增渠道含/不含未配置说明、网页 notice 一致性、SOP 入口窗口、超预算降级、无入口事件回退、会话/团队删除级联取消等回归);前端 246 passed(新增 ChatDialogs 卡片测试),build / i18n:check / config:check 通过。 UI 验证:admin 角色在浏览器打开"待回答"收件箱确认统一卡片渲染;飞书侧触发转人工确认通知头部含转接对象说明。 |
|
补充说明:转人工通知的消息格式也已重构( 此前渠道端给处理人的通知是平铺式结构,信息挤压在一起靠冒号区分,实际效果(真实客户案例节选): 主要问题:同一信息重复 3 次(用户原话 / slot 展开 / 聚合 slot 重复序列化)、英文 slot 键对处理人不可读、上下文仅回看 2 条且在句中硬截断、SOP 名称不展示。 更改后的格式: 结构说明:
|
- service_intake: keep DingTalk trace streamer import alongside upstream WeCom stream reply sink initialization - service_outbox: keep unified handoff notice builder from app.core.handoff_notice, adopt upstream channel-specific reply footer (feishu quote-reply vs /回复反馈 <handoff_id> for other channels) - human_handoff_service: drop duplicated resolver calls after upstream moved them before the existing-handoff check, keep toggle comment
Router reason/user_intent 可能夹带 conversation 等内部枚举值并原样 渲染到飞书/钉钉执行卡片。在 TraceStreamer 渲染层净化无 SOP 轮次的 展示文案:已知枚举映射中文、其余英文删除,保留「SOP」与用户原文 复述的英文;入库事件数据不变。同时约束 Router prompt 输出中文, 并将本轮用户消息传入流式器用于白名单判断。
|
新增提交: 背景:客户在 SOP 编辑器修改数字员工 SOP的转人工节点的节点说明时被拒绝,报错「人工节点处理人在租户内可用的飞书绑定作用域下未绑定渠道身份,无法按该渠道转接」。实际该处理人(admin)的飞书身份与绑定是同企业同应用的,属于误判。 根因:启动迁移 改动:
验证:用客户真实数据库副本复现报错并确认修复后校验通过;后端全量 2120 passed / 11 failed(失败项与改动前完全一致,均为存量问题);ruff 无新增告警。 |
|
本 PR 新增一条修复:网页控制台发起的回合不再向外部渠道(飞书等)推送回复(d35b082)。 问题:之前投递决策只看会话的 修复方案(按回合来源决定是否投递):
修复后的行为:
测试:新增 3 个回归测试(web 来源不投递 / 渠道来源正常投递 / legacy 数据保持投递),更新 2 个 metadata 断言。全套件 2103 passed,失败项与改动前完全一致(均为遗留问题,已逐一比对确认);ruff 无新增问题。 |
|
新增一条飞书修复:reaction 登记静默跳过 + 入站 target 污染(b784e74,均为 upstream 回归,经 merge upstream/main 带入)。 问题 1:飞书"处理中"✅ reaction 不再登记(
问题 2:飞书群聊会话 target 混入 wecom 风格键(
测试: |
Summary
Introduce a shared
trace_streamercore that drives AI trace cards for both Feishu and DingTalk, replacing the previous Feishu-only inline implementation.flowStatusstate transitions (processing / input / complete / failed), threaded through the DingTalk adapter and service intake.Intent & risk
Enables real-time AI trace cards in DingTalk alongside the existing Feishu support. The refactor consolidates shared streaming logic, so the main risk is regression of existing Feishu trace cards; covered by the test suite below.
Tests run
backend/.venv/bin/python -m pytest backend/tests/test_channel_dingtalk.py backend/tests/test_dingtalk_trace_streamer.py backend/tests/test_feishu_trace_streamer.py backend/tests/test_chat_trace.py— 153 passed.backend/.venv/bin/ruff checkon changed files — no new issues introduced (pre-existing SIM/UP041/DTZ warnings unchanged).UI validation
DingTalk interactive card rendering requires live channel credentials; visual verification performed locally via the DingTalk test robot.