feat: add workflow action runtime policies

This commit is contained in:
Xin Wang
2026-07-31 23:30:04 +08:00
parent c2f0f5eb04
commit f155f98e6e
10 changed files with 445 additions and 71 deletions

View File

@@ -92,6 +92,60 @@ class WorkflowGraphTests(unittest.TestCase):
agent["data"]["entrySpeech"] = "您好,{{customer}}"
self.assertEqual(validate_graph(normalized), [])
def test_action_defaults_preserve_legacy_result_assignment_behavior(self):
graph = valid_graph()
graph["nodes"].extend(
[
{
"id": "legacy_override",
"type": "action",
"data": {"resultAssignments": {"status": "order.status"}},
},
{"id": "legacy_none", "type": "action", "data": {}},
{
"id": "explicit_inherit",
"type": "action",
"data": {"resultAssignmentMode": "inherit"},
},
]
)
normalized = normalize_graph(graph)
actions = {
node["id"]: node["data"]
for node in normalized["nodes"]
if node["type"] == "action"
}
self.assertEqual(
actions["legacy_override"]["resultAssignmentMode"], "override"
)
self.assertEqual(actions["legacy_none"]["resultAssignmentMode"], "none")
self.assertEqual(
actions["explicit_inherit"]["resultAssignmentMode"], "inherit"
)
self.assertEqual(actions["legacy_none"]["resultAssignments"], {})
self.assertEqual(actions["legacy_none"]["userInputPolicy"], "queue")
def test_action_advanced_settings_are_validated(self):
graph = valid_graph()
graph["nodes"].append(
{
"id": "action",
"type": "action",
"data": {
"resultAssignmentMode": "unexpected",
"resultAssignments": [],
"userInputPolicy": "cancel",
},
}
)
errors = validate_graph(graph)
self.assertTrue(any("结果变量模式无效" in error for error in errors))
self.assertTrue(any("结果变量映射必须是对象" in error for error in errors))
self.assertTrue(any("用户输入策略无效" in error for error in errors))
def test_voice_resource_creates_isolated_runtime_config(self):
base = AssistantConfig(type="workflow", asr="default", voice="default")
asr = RuntimeModelResource(