Skip to content

fix: isolate retry state in parallel batches - #148

Open
Iams4kura wants to merge 1 commit into
The-Pocket:mainfrom
Iams4kura:bugfix/isolate-parallel-retry-state-20260823t163924z
Open

fix: isolate retry state in parallel batches#148
Iams4kura wants to merge 1 commit into
The-Pocket:mainfrom
Iams4kura:bugfix/isolate-parallel-retry-state-20260823t163924z

Conversation

@Iams4kura

Copy link
Copy Markdown

Summary

  • Fixes: With two concurrently retried AsyncParallelBatchNode items, one item's first failure can be mistaken for its final attempt and enter fallback before using its configured retry.
  • Root cause: AsyncNode._exec stores cur_retry as an instance attribute on the shared node while AsyncParallelBatchNode runs every item concurrently on that instance. A ContextVar preserves the public self.cur_retry API while isolating the value in each asyncio task.

Regression evidence

  • Before: python3 -m unittest tests.test_async_parallel_batch_node.TestAsyncParallelBatchNode.test_retry_state_is_isolated_per_item -v exited 1

  • After: python3 -m unittest tests.test_async_parallel_batch_node.TestAsyncParallelBatchNode.test_retry_state_is_isolated_per_item -v exited 0

Verification

  • python3 -m unittest tests.test_async_parallel_batch_node -v
  • python3 -m unittest discover -s tests -p 'test_*.py' -v
  • python3 -m compileall -q pocketflow

Scope

  • 2 files changed, +41 / -3 lines

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