From 22198ba4afb12fdab929a932a42f52732eb8024a Mon Sep 17 00:00:00 2001 From: zxstty Date: Thu, 31 Jul 2025 00:13:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dchoice=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E5=88=86=E6=94=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/scheduler/call/choice/choice.py | 2 +- apps/scheduler/call/choice/condition_handler.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/apps/scheduler/call/choice/choice.py b/apps/scheduler/call/choice/choice.py index 64f44d961..c050482c6 100644 --- a/apps/scheduler/call/choice/choice.py +++ b/apps/scheduler/call/choice/choice.py @@ -146,7 +146,7 @@ class Choice(CoreCall, input_model=ChoiceInput, output_model=ChoiceOutput): logger.warning(f"[Choice] 分支 {choice.branch_id} 条件处理失败: {error_msg}") # 如果没有有效条件,返回失败 - if not valid_conditions: + if not valid_conditions and not choice.is_default: error_messages.append("分支没有有效条件") return False, error_messages diff --git a/apps/scheduler/call/choice/condition_handler.py b/apps/scheduler/call/choice/condition_handler.py index 07e8a5e55..6b8fa3fc9 100644 --- a/apps/scheduler/call/choice/condition_handler.py +++ b/apps/scheduler/call/choice/condition_handler.py @@ -77,10 +77,10 @@ class ConditionHandler(BaseModel): """处理条件""" default_branch = [c for c in choices if c.is_default] - for block_judgement in choices: + for block_judgement in choices[::-1]: results = [] if block_judgement.is_default: - continue + return default_branch[0].branch_id for condition in block_judgement.conditions: result = ConditionHandler._judge_condition(condition) results.append(result) @@ -91,10 +91,7 @@ class ConditionHandler(BaseModel): if final_result: return block_judgement.branch_id - - # 如果没有匹配的分支,选择默认分支 - if default_branch: - return default_branch[0].branch_id + return "" @staticmethod -- Gitee