Skip to content

fix: The form in the loop body will not pause the outer layer - #8222

Merged
shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_loop
Nov 30, 2026
Merged

shaohuzhang1 merged 1 commit into
v3from
pr@v3@fix_loop

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: The form in the loop body will not pause the outer layer

@shaohuzhang1
shaohuzhang1 merged commit 3e2c8f7 into v3 Nov 30, 2026
3 of 4 checks passed
@shaohuzhang1
shaohuzhang1 deleted the pr@v3@fix_loop branch November 30, 2026 08:20

if wf_manage.signal == Signal.CONTINUE:
self._run_next()
return

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's my review of the diff:

Issues / Observations

1. Behavior change may break existing callers

Previously, Signal.BREAK and Signal.FORM were handled identically (complete with Status.SUCCESS). Now FORM completes with an extra signal=Signal.FORM argument. Check that self.complete() actually accepts a signal keyword — if not defined or if it doesn't propagate the signal upstream correctly, this will raise TypeError or silently drop the signal. Confirm the signature and downstream handling of the propagated signal.

2. Duplicated run_time computation

The line:

self.data["run_time"] = time.time() - self.data.get("start_time", time.time())

is now duplicated in both branches. Consider factoring it out before the branch, or into a small helper, to reduce drift risk.

3. Signal.FORM propagation must be handled by parent

The comment says "propagate interrupt upward, pause parent workflow, resume at position after user submit." Verify:

  • The parent on_complete handler actually inspects the child's returned signal (e.g., wf_manage.result.signal or wherever complete(..., signal=...) stores it).
  • There is logic to persist the current position so resumption works. If no such resume mechanism exists yet, the new behavior will complete the loop body but not actually pause/resume — it could silently end the loop iteration instead.

4. Status.SUCCESS for a "paused/awaiting form" state is semantically questionable

Completing with Status.SUCCESS while emitting Signal.FORM conflates "finished successfully" with "interrupted awaiting input." Consider a distinct status (e.g., Status.PAUSED / Status.AWAITING_FORM) to make the state explicit and avoid mistaking it for a normal completion in metrics/logging.

5. Idempotency / repeated submission

If the parent re-invokes the loop body after form submission, ensure start_time and run_time are not double-counted (run_time is rewritten each time — likely fine, but confirm start_time isn't reset on resume).

6. Missing test coverage note

This is a control-flow change for interruptions. Ensure tests cover: BREAK path unchanged, FORM path sets the propagated signal, and the parent resumes via position.

7. Minor: readability

An elif chain would read more clearly than sequential if ... return blocks when all conditions are mutually exclusive signals:

if wf_manage.signal == Signal.BREAK:
    ...
elif wf_manage.signal == Signal.FORM:
    ...
elif wf_manage.signal == Signal.CONTINUE:
    ...

Summary

Main risks: (a) complete(signal=...) must exist and be consumed by the parent; (b) the resume-at-position machinery must actually exist, otherwise FORM interruption won't work as intended; (c) using SUCCESS for a paused state is misleading. Validate these before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant