feat: add workflow action runtime policies
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user