Repository navigation
Python: Preserve concurrent steps across workflow pause - #9291
Eduard van Valkenburg (eavanvalkenburg) merged 10 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Task settlement can incorrectly re-raise previously handled task failures.
1 open finding
What changed in this PR
Preserves concurrent functional-workflow steps across HITL pauses to prevent duplicate side effects.
Changes:
- Tracks and settles active nested steps before snapshots.
- Cancels detached workflow tasks.
- Handles interruption-only and mixed exception groups.
| File | Description |
|---|---|
_functional.py |
Implements task settlement and interruption-group handling. |
test_functional_workflow.py |
Adds concurrency, cancellation, and TaskGroup regressions. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (2 commit(s)): 1009056cffa8, 6db8e3b491a0
Model: gpt-5.6-sol
Overview
The change adds active-step tracking, task draining, and exception-group normalization, with focused tests for gather, cancellation, nested steps, and TaskGroup interruption. Those guards cover cooperative gather-based pauses well, but TaskGroup sibling cancellation still permits duplicate side effects, and the settlement path mistakes concurrently handled failures for unhandled ones. Both residual defects affect whether a workflow can pause and resume without repeating work or replacing the pause with an error.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
2 verified findings remained after source verification (1 high, 1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: python/packages/core/agent_framework/_workflows/_functional.py
6db8e3b to
7b41287
Compare
7b41287 to
e8779d6
Compare
b049c42 to
553222e
Compare
553222e to
b57de60
Compare
c6b35ff to
0174f38
Compare
0174f38 to
74d660a
Compare
74d660a to
072be62
Compare
072be62 to
ee61389
Compare

Motivation & Context
Functional workflows could capture HITL replay and checkpoint state while a concurrent
@stepwas still running. The step then completed after the paused run returned, so resume executed it again and could duplicate model, tool, or write side effects.asyncio.TaskGroupalso exposed the internal interruption as aBaseExceptionGroup.This change settles active concurrent steps before pause state is captured, while cancelling detached workflow tasks so a pause cannot leave background work running.
Description & Review Guide
@stepexecutions, await those tasks before HITL replay/checkpoint capture, cancel and drain remaining detached tasks, and separate internal interruption leaves from real exception-group failures.TaskGroup-based workflows pause and resume through the normal HITL path.Related Issue
Closes #9268
AI Assistance
AI assistance details: Implementation, tests, design review, and PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.