Automate Event Planning - The crew must end with at most one asynchronous task

Hi! I’m getting this error when I try to create the Crew as it is in the notebook.

ValidationError: 1 validation error for Crew
  The crew must end with at most one asynchronous task. [type=async_task_count, input_value={'agents': [Agent(role=Ve...own.)], 'verbose': True}, input_type=dict]

I’m using the crewAI version 0.51.1. I know it is a different version compared to the one in the sandbox lab. But I’d like to understand what I need to change to make it work.

My agents:

venue_coordinator = Agent(
    role="Venue Coordinator",
    goal="Identify and book an appropriate venue "
    "based on event requirements",
    tools=[search_tool, scrape_tool],
    verbose=True,
    backstory=(
        "With a keen sense of space and "
        "understanding of event logistics, "
        "you excel at finding and securing "
        "the perfect venue that fits the event's theme, "
        "size, and budget constraints."
    )
)

 # Agent 2: Logistics Manager
logistics_manager = Agent(
    role='Logistics Manager',
    goal=(
        "Manage all logistics for the event "
        "including catering and equipmen"
    ),
    tools=[search_tool, scrape_tool],
    verbose=True,
    backstory=(
        "Organized and detail-oriented, "
        "you ensure that every logistical aspect of the event "
        "from catering to equipment setup "
        "is flawlessly executed to create a seamless experience."
    )
)

# Agent 3: Marketing and Communications Agent
marketing_communications_agent = Agent(
    role="Marketing and Communications Agent",
    goal="Effectively market the event and "
         "communicate with participants",
    tools=[search_tool, scrape_tool],
    verbose=True,
    backstory=(
        "Creative and communicative, "
        "you craft compelling messages and "
        "engage with potential attendees "
        "to maximize event exposure and participation."
    )
)

Taks

venue_task = Task(
    description="Find a venue in {event_city} "
                "that meets criteria for {event_topic}.",
    expected_output="All the details of a specifically chosen"
                    "venue you found to accommodate the event.",
    human_input=True,
    output_json=VenueDetails,
    output_file="venue_details.json",  
      # Outputs the venue details as a JSON file
    agent=venue_coordinator
)

logistics_task = Task(
    description="Coordinate catering and "
                 "equipment for an event "
                 "with {expected_participants} participants "
                 "on {tentative_date}.",
    expected_output="Confirmation of all logistics arrangements "
                    "including catering and equipment setup.",
    human_input=True,
    async_execution=True,
    agent=logistics_manager
)

marketing_task = Task(
    description="Promote the {event_topic} "
                "aiming to engage at least"
                "{expected_participants} potential attendees.",
    expected_output="Report on marketing activities "
                    "and attendee engagement formatted as markdown.",
    async_execution=True,
    output_file="marketing_report.md",  # Outputs the report as a text file
    agent=marketing_communications_agent
)

Crew

# Define the crew with agents and tasks
event_management_crew = Crew(
    agents=[venue_coordinator, 
            logistics_manager, 
            marketing_communications_agent],
    
    tasks=[venue_task, 
           logistics_task, 
           marketing_task],
    
    verbose=True
)
2 Likes

I had the same issue as well. I turned off the asynchronous flag for logistics manager.

2 Likes

I did as well. I’m curious what the correct approach would be here though.

After setting only one async task, it worked anyway. For examle, just turned off the flag of maketing task’s async_execution.

I agree with @diem389, it only works with a single asynchronous task as mentioned in the error message.

As per my understanding running multiple tasks asynchronously within a single Crew could create significant complexity in coordinating task completions, handling dependencies between them, and meaningfully aggregating results.

There is potentially great benefit to being able to execute multiple tasks asynchronously.
Let’s say we have tasks = [task1_sync, task2_async, task3_async, task4_sync]

  1. task1_sync starts out the research
  2. task2_async and task3_async are allowed to execute in parallel (e.g. one collects data from an SQL database and another scrapes the web). (We can save time here!)
  3. task4_sync can aggregate and prepare the report

Ideally, specifying the dependency such that there is only ONE “last task” should theoretically pass the validation e.g.

marketing_task = Task(
    description="Promote the {event_topic} aiming to engage at least{expected_participants} potential attendees.",
    expected_output="Report on marketing activities and attendee engagement formatted as markdown.",
    async_execution=True,
    output_file="marketing_report.md",  # Outputs the report as a text file
    agent=marketing_communications_agent,
    context=[logistics_task, venue_task],
)

Unfortunately, the validation implementation is quite strict.

Hence, to overcome the restriction, we can make the last task in tasks synchronous.
To save LLM costs, we would need to create a custom dummy LLM (seems to have a lot of angles to test/cover: Custom LLM Implementation - CrewAI ) and dummy task…

I am using

crewai==0.119.0
crewai-tools==0.44.0