address review: skip copy-back on paused/failed iterations

Move the status check before the copy-back so that partial results
from paused or failed nested steps (e.g., a gate awaiting input)
do not overwrite the unprefixed key. This preserves correct resume
behavior.
This commit is contained in:
Manfred Riem
2026-05-21 09:36:36 -05:00
parent 093d248e4b
commit f8019eba84

View File

@@ -695,18 +695,21 @@ class WorkflowEngine:
iter_steps, context, state, registry,
step_offset=-1,
)
# Copy namespaced results back to unprefixed
# keys so loop conditions see updated values.
for namespaced, orig in original_ids.items():
if namespaced in context.steps:
context.steps[orig] = context.steps[namespaced]
state.step_results[orig] = context.steps[namespaced]
if state.status in (
RunStatus.PAUSED,
RunStatus.FAILED,
RunStatus.ABORTED,
):
return
# Copy namespaced results back to unprefixed
# keys so loop conditions see updated values.
# Only after a fully completed iteration —
# partial results from paused/failed steps
# must not overwrite the unprefixed key.
for namespaced, orig in original_ids.items():
if namespaced in context.steps:
context.steps[orig] = context.steps[namespaced]
state.step_results[orig] = context.steps[namespaced]
# Fan-out: execute nested step template per item with unique IDs
if step_type == "fan-out":