feat(chat): 透传培训agent账号角色到dify

This commit is contained in:
runny committed 2026-07-07 05:05:13 +08:00
1 parent fd024c1c32
commit 9ea49d7060
5 files changed
+114 -4

No files matched your search

@@ -145,6 +145,36 @@ def test_build_chat_dify_inputs_falls_back_to_generic_adapter(monkeypatch):
}
def test_build_chat_dify_inputs_appends_role_for_training_agent(monkeypatch):
"""培训 Agent 对接 Dify 时应额外透传后台账号角色,普通 generic 输入保持不变。"""
agent = SimpleNamespace(
name="员工培训 Agent",
extra_config={"training_workspace_enabled": True},
)
monkeypatch.setattr(dify_inputs_module, "is_shipping_notice_chat_agent", lambda _: False)
monkeypatch.setattr(dify_inputs_module, "agent_declares_file_check_progress", lambda _: False)
monkeypatch.setattr(dify_inputs_module, "is_file_check_chat_agent", lambda _: False)
monkeypatch.setattr(
dify_inputs_module,
"build_generic_dify_inputs",
lambda **kwargs: {
"agent_runtime_context": '{"agent_code":"training_agent"}',
},
)
inputs = build_chat_dify_inputs(
agent,
session_id="conv-training-001",
user_role="hr",
)
assert inputs == {
"agent_runtime_context": '{"agent_code":"training_agent"}',
"role": "hr",
}
def test_build_chat_dify_inputs_ignores_invalid_shipping_hints(monkeypatch):
"""shipping hints 非字典时应安全回退为空,避免平台入口依赖脏业务结构。"""
agent = SimpleNamespace(name="货代发货通知 Agent", extra_config={})