[BUG] Hierarchical example from documentation doesn't work
Opened this issue · 6 comments
Description
I'm following this how to documentation to start on hierarchical process
https://docs.crewai.com/how-to/hierarchical-process#hierarchical-process
I had to add kickoff call to make it run
from langchain_openai import ChatOpenAI
from crewai import Crew, Process, Agent
# Agents are defined with attributes for backstory, cache, and verbose mode
researcher = Agent(
role='Researcher',
goal='Conduct in-depth analysis',
backstory='Experienced data analyst with a knack for uncovering hidden trends.',
cache=True,
verbose=True,
# tools=[] # This can be optionally specified; defaults to an empty list
use_system_prompt=True, # Enable or disable system prompts for this agent
max_rpm=30, # Limit on the number of requests per minute
max_iter=5 # Maximum number of iterations for a final answer
)
writer = Agent(
role='Writer',
goal='Create engaging content',
backstory='Creative writer passionate about storytelling in technical domains.',
cache=True,
verbose=True,
# tools=[] # Optionally specify tools; defaults to an empty list
use_system_prompt=True, # Enable or disable system prompts for this agent
max_rpm=30, # Limit on the number of requests per minute
max_iter=5 # Maximum number of iterations for a final answer
)
# Establishing the crew with a hierarchical process and additional configurations
project_crew = Crew(
tasks=[], # Tasks to be delegated and executed under the manager's supervision
agents=[researcher, writer],
manager_llm=ChatOpenAI(temperature=0, model="gpt-4o-mini"), # Mandatory if manager_agent is not set
process=Process.hierarchical, # Specifies the hierarchical management approach
#respect_context_window=True, # Enable respect of the context window for tasks
memory=True, # Enable memory usage for enhanced task execution
manager_agent=None, # Optional: explicitly set a specific agent as manager instead of the manager_llm
planning=True, # Enable planning feature for pre-execution strategy
verbose=True,
)
# Kick off the crew's work
results = project_crew.kickoff()
# Print the results
print("Crew Work Results:")
print(results)
Steps to Reproduce
python test.py
Expected behavior
Crew run and produce result
Screenshots/Code snippets
See evidence
Operating System
macOS Sonoma
Python Version
3.11
crewAI Version
0.74.2
crewAI Tools Version
0.13.2
Virtual Environment
Conda
Evidence
[2024-10-20 20:25:21][INFO]: Planning the crew execution
Traceback (most recent call last):
File "/Users/user/Documents/GitHub/crewai-updated-tutorial-hierarchical/test.py", line 42, in <module>
results = project_crew.kickoff()
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/envs/crewai-311/lib/python3.11/site-packages/crewai/crew.py", line 495, in kickoff
result = self._run_hierarchical_process()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/envs/crewai-311/lib/python3.11/site-packages/crewai/crew.py", line 602, in _run_hierarchical_process
return self._execute_tasks(self.tasks)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/envs/crewai-311/lib/python3.11/site-packages/crewai/crew.py", line 707, in _execute_tasks
return self._create_crew_output(task_outputs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/miniconda3/envs/crewai-311/lib/python3.11/site-packages/crewai/crew.py", line 811, in _create_crew_output
raise ValueError(
ValueError: Something went wrong. Kickoff should return only one task output.
Possible Solution
None
Additional context
None
I found that task is missing in this example and added following task:
task = Task(
description='Write engaging blog post on CrewAI',
agent=writer,
expected_output='Markdown formatted text',
)
However in this case execution is fall into endless loop with error:
## Tool Output:
Error: the Action Input is not a valid key, value dictionary.
@tonykipkemboi can we have a working example on the docs ?
You can define those tasks without an agent defined. @ernestp Yes. just add a couple of tasks there. the manager agent will then decide which agent to execute the task with.
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
I'll look into this tomorrow. Thanks for flagging @lorenzejay
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.