The ConcurrentWorkflow class was raising an AttributeError because the tasks attribute was not properly initialized in the class constructor. When the run() method attempted to access self.tasks, it failed because the attribute didn't exist. This caused workflows to fail when trying to execute tasks, particularly affecting use cases where tasks were added incrementally or when running multiple tasks in sequence.
Root Cause:
The tasks attribute was missing from the class's init method
The code assumed the existence of self.tasks but never properly initialized it
This caused the workflow to fail immediately upon attempting to access the tasks list
Solution:
The fix implements the following changes:
Added proper initialization of self.tasks = [] in the init method
Modified the task handling logic to append tasks when they're provided to the run() method
Ensured the tasks list is always available, even if empty
Added proper type hints and documentation for the tasks attribute
Benefits:
Prevents AttributeError when accessing tasks
Allows for both single-task and multi-task execution
Maintains state of tasks throughout the workflow's lifecycle
Improves code reliability and predictability
Breaking Changes:
None. This is a backward-compatible fix that maintains the existing API while resolving the underlying issue.
Description:
The ConcurrentWorkflow class was raising an AttributeError because the tasks attribute was not properly initialized in the class constructor. When the run() method attempted to access self.tasks, it failed because the attribute didn't exist. This caused workflows to fail when trying to execute tasks, particularly affecting use cases where tasks were added incrementally or when running multiple tasks in sequence.
Root Cause:
Solution:
The fix implements the following changes:
Benefits:
Breaking Changes:
Related Issues: Fixes #511
📚 Documentation preview 📚: https://swarms--613.org.readthedocs.build/en/613/