fix(workflow): preserve loop body failures#80
Open
WeiXianyang wants to merge 1 commit into
Open
Conversation
Workflow loops currently evaluate break_if after executing the loop body even when the body has already reported a stopping failure.
That behavior can mask the original failure. For example, runner/mobiagent/workflow/examples/01_basic_gui_task_weixin_v2.json checks:
${steps.2.output.structured_output.contains_today_chat}
When the vlm_qa tool step fails, its output is empty. The loop then tries to evaluate break_if anyway and raises a secondary 'structured_output' KeyError instead of preserving the original tool failure.
Why this should be changed
The loop body failure is the actionable error. Evaluating break_if after a failed body depends on outputs that may not exist, and it can replace the real failure with a misleading variable-resolution error.
The condition is still evaluated after successful loop body iterations, so workflows such as the Weixin v2 chat collection flow can continue to use local loop aliases like steps.2 to read the current iteration's vlm_qa structured output.
This patch intentionally keeps the change minimal:
it only skips break_if evaluation when the loop body has already stopped
it does not change loop alias resolution
it adds regression coverage for both the failure path and the successful current-iteration break_if path
Impact
Preserves the original loop body failure in workflow summaries and logs.
Avoids misleading 'structured_output' KeyError failures after a tool step has already failed.
Keeps successful loop break_if behavior unchanged for current-iteration tool outputs.
Signed-off-by: 23301078 <23301078@bjtu.edu.cn>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Workflow loops currently evaluate break_if after executing the loop body even when the body has already reported a stopping failure.
That behavior can mask the original failure. For example, runner/mobiagent/workflow/examples/01_basic_gui_task_weixin_v2.json checks:
${steps.2.output.structured_output.contains_today_chat}
When the vlm_qa tool step fails, its output is empty. The loop then tries to evaluate break_if anyway and raises a secondary 'structured_output' KeyError instead of preserving the original tool failure.
Why this should be changed
The loop body failure is the actionable error. Evaluating break_if after a failed body depends on outputs that may not exist, and it can replace the real failure with a misleading variable-resolution error.
The condition is still evaluated after successful loop body iterations, so workflows such as the Weixin v2 chat collection flow can continue to use local loop aliases like steps.2 to read the current iteration's vlm_qa structured output.
This patch intentionally keeps the change minimal:
it only skips break_if evaluation when the loop body has already stopped it does not change loop alias resolution
it adds regression coverage for both the failure path and the successful current-iteration break_if path
Impact
Preserves the original loop body failure in workflow summaries and logs. Avoids misleading 'structured_output' KeyError failures after a tool step has already failed. Keeps successful loop break_if behavior unchanged for current-iteration tool outputs.