Dynamic Task Execution in CrewAI: Ensuring Only Relevant Agents Run Based on User Intent

Problem Statement:
I am building a multi-agent system using CrewAI where:

  • A Router Agent determines if a user query is about scheduling or company information.
  • A RAG Agent answers company-related queries.
  • A Schedule Agent handles scheduling queries.

Issue:
Currently, all tasks execute regardless of the user’s intent. If the user asks about scheduling, the company info task also runs (and vice versa).

Goal:
I need a solution where:

  • The Router Agent classifies the intent.
  • Only the relevant agent executes based on the classification (without running unnecessary tasks).
  • The system remains efficient and scalable for future agents.

Have you looked at Flows? They make such features easy to make and are more detrministic Flows - CrewAI

Thank you for your response. I have successfully tackled this problem using ConditionalTask.

Is this the best way to handle it?

I’m glad you got it working. There isn’t one way to handle agents, you pick the one that solves your issue in a straightforward way depending on the circumstances.

Thank u for Your guidance