Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

perf: Implemented short-circuit evaluation for logical conditions (#13674)

llinvokerl33a565a71903
diff --git a/api/core/workflow/utils/condition/processor.py b/api/core/workflow/utils/condition/processor.py
index 19473f39d22..c61b3d1861c 100644
--- a/api/core/workflow/utils/condition/processor.py
+++ b/api/core/workflow/utils/condition/processor.py
@@ -64,6 +64,10 @@ class ConditionProcessor:
expected=expected_value,
)
group_results.append(result)
+ # Implemented short-circuit evaluation for logical conditions
+ if (operator == "and" and not result) or (operator == "or" and result):
+ final_result = result
+ return input_conditions, group_results, final_result
final_result = all(group_results) if operator == "and" else any(group_results)
return input_conditions, group_results, final_result