Skip to content

[BUG] Workflow Tool loops infinitely with duplicate task name in different workflow execution #244

@dominikschweigl

Description

@dominikschweigl

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

1.8.0

Tools Package Version

0.2.7

Tools used

  1. Workflow tool

Python Version

3.10.18

Operating System

Amazon Linux 2 - 5.10.240-218.959.amzn2int.x86_64

Installation Method

pip

Steps to Reproduce

  1. Code Snippet (Minimum reproducible example)

Run two workflows that contain a task with the same name like this example:

import asyncio

import boto3
from botocore.config import Config
from strands import Agent
from strands.models import BedrockModel
from strands_tools import workflow


async def main():
   
    # Create a basic strands agent with workflow tool
    agent = Agent(
        model=<your-model>,  
        system_prompt="You are a helpful assistant for testing workflows.",
        tools=[workflow],  # Add workflow tool directly
        messages=[],
    )

    base_workflow_id = "test_workflow"

    # First execution with ID suffix
    first_execution_id = f"{base_workflow_id}_1"
    agent.tool.workflow(
        action="create",
        workflow_id=first_execution_id,
        tasks=[
            {
                "task_id": "simple_task",
                "description": "Say hello and return a simple greeting message",
                "priority": 3,
            }
        ],
        agent=agent,
    )
    agent.tool.workflow(action="start", workflow_id=first_execution_id)

    # Second execution with different ID suffix
    second_execution_id = f"{base_workflow_id}_2"
    agent.tool.workflow(
        action="create",
        workflow_id=second_execution_id,
        tasks=[
            {
                "task_id": "simple_task",
                "description": "Say hello and return a simple greeting message",
                "priority": 3,
            }
        ],
        agent=agent,
    )
    agent.tool.workflow(action="start", workflow_id=second_execution_id)


if __name__ == "__main__":
    asyncio.run(main())
  1. Install the needed packages using pip and configure your model

  2. Output

When running this code, the second workflow is stuck in an infinite loop and the output is:

Hello! I'm here to help you test workflows using the advanced workflow orchestration system.

I can assist you with:

    Creating multi-task workflows with different AI models
    Starting and monitoring workflow execution
    Managing workflow dependencies and priorities
    Configuring per-task tools and model settings
    Tracking workflow progress and status

Error loading workflow test_workflow_2: Expecting value: line 1 column 1 (char 0)

Expected Behavior

I would expect the workflow tool to execute the workflow without errors despite the existence of previously run tasks with the same name.

Actual Behavior

The workflow tool throws the error Error loading workflow test_workflow_2: Expecting value: line 1 column 1 (char 0) on the second execution of a workflow with the same task name. In addition, the workflow tool is stuck in an infinite loop.

Additional Context

No response

Possible Solution

This problem is due to the TaskExecutor already having a task with this name in it's execution history as completed. The task of the second workflow execution is therefore not added to it's active tasks.

Since there are no pending tasks in TaskExecutor, the WorkflowManager does not receive the task completion of the workflow tasks. This results in the WorkflowManager infinitely waiting for the pending task in the second workflow execution.

The easiest fix I found is to reinstantiate a new TaskExecutor for the WorkflowManager class after every workflow execution.

Related Issues

No response

Internal Ticket ID

D308431709

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions