CrewAI Planning and Reasoning
CrewAI provides reasoning and planning parameters that influence how outputs are generated. These two features are distinct but when used together, they can lead to more structured and transparent results.
1. Understanding Reasoning
Reasoning is applied at the agent level. It determines whether the agent should explain how it arrives at the answer.
- When reasoning is set to False, the agent produces only the final output.
- When reasoning is set to True, the agent outlines the thought process step by step.
This is useful when clarity and traceability of the solution are required.
2. Understanding Planning
Planning is applied at the crew level. It determines whether the crew first builds a structured plan before executing the task.
- When planning is set to False, the agent attempts the task directly.
- When planning is set to True, the crew drafts an outline of how the work will be carried out before execution.
This helps when tasks are multi-day or multi-step such as designing agendas, roadmaps or workflows.
Why Use Planning and Reasoning Together?
Reasoning and planning complement each other in different ways.
- Reasoning makes the agent explain its thought process step by step, adding transparency and clarity.
- Planning organizes the workflow before execution, ensuring that complex tasks are handled in a structured way.
When used together they produce outputs that are both well-structured and clearly explained. For example, in the workshop task, planning creates a coherent agenda while reasoning explains why each session is placed. This combination is most useful for tasks that require both structure and justification such as project planning, research or curriculum design.
Implementation of CrewAI Agents with Planning and Reasoning
We will be implementing a CrewAI agent to demonstrate how planning and reasoning influence the way tasks are executed and explained
1. Without Reasoning and Planning
We will implement a CrewAI agent with both reasoning and planning disabled.
- The agent is defined with a role, goal and backstory but reasoning=False.
- The task remains the same, asking for a 3-day AI workshop agenda.
- The crew is created with the agent and task while planning=False means no structured planning is applied.
import os
os.environ["OPENAI_API_KEY"]="Your_API_Key"
from crewai import Agent, Task, Crew
workshop_agent_simple = Agent(
role="Event Planner",
goal="Create a 3-day AI workshop agenda",
backstory="Experienced in planning multi-day technical workshops",
reasoning=False,
verbose=True
)
agenda_task_simple = Task(
description="Plan a detailed 3-day workshop agenda with sessions, speakers, and prerequisites",
expected_output="A well-structured 3-day agenda",
agent=workshop_agent_simple
)
crew_without_planning = Crew(
agents=[workshop_agent_simple],
tasks=[agenda_task_simple],
planning=False,
verbose=True
)
result = crew_without_planning.kickoff()
print(result)
Output:
2. With Reasoning and Planning
We will implement a CrewAI agent with both reasoning and planning enabled.
- The agent is defined with a role, goal and backstory along with reasoning=True.
- The task specifies the description and expected output for a 3-day AI workshop agenda.
- The crew is created with the agent and task while planning=True ensures structured execution.
import os
os.environ["OPENAI_API_KEY"]="Your_API_key"
from crewai import Agent, Task, Crew
workshop_agent = Agent(
role="Event Planner",
goal="Create a 3-day AI workshop agenda",
backstory="Experienced in planning multi-day technical workshops",
reasoning=True,
verbose=True
)
agenda_task = Task(
description="Plan a detailed 3-day workshop agenda with sessions, speakers, and prerequisites",
expected_output="A well-structured 3-day agenda",
agent=workshop_agent
)
crew_with_planning = Crew(
agents=[workshop_agent],
tasks=[agenda_task],
planning=True,
verbose=True
)
result = crew_with_planning.kickoff()
print(result)
Output:
Comparing Outputs
When reasoning and planning are disabled:
- The output is direct but unstructured.
- The agent provides an agenda with sessions and timings, but there is little to no explanation of why those choices were made or how the schedule fits together.
- This approach may work for simple tasks but lacks clarity for complex ones.
With reasoning and planning enabled:
- The process changes noticeably.
- The agent first outlines a plan, showing how it will approach the task.
- It then provides reasoning to justify decisions such as the order of sessions, inclusion of prerequisites or balance of topics.
- Finally, it delivers a well-structured 3-day agenda that is both organized and supported by explanations. This makes the output easier to understand, validate and refine.