crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
18.92k stars 2.6k forks source link

Stuck while executing the Crew. #642

Closed felixgao closed 1 week ago

felixgao commented 3 months ago

Hi I have a very simple Crew and it seems to be stuck (30 minutes without anything showing up after the previous prompt) while executing the crew. I am not sure if that is normal or not.

This is the output that I am seeing and I have to ctrl-c to stop it.

python crew.py
 [DEBUG]: == Working Agent: Story Researcher
 [INFO]: == Starting Task: Research and compile information on popular children's books, including summaries, author biographies, and reviews.
            Provide a curated list of recommended children's books based on various themes, age groups, and genres.
            Additionally, gather resources such as educational activities, discussion guides, and related websites to supplement the reading experience.
            Present the findings in JSON format.

            Important:
                - Limit the number of results to 10.
                - The final list of JSON objects must include the following fields: "title", "author", "genre", "summary", "age_groups", "reviews", "educational_activities", "discussion_guides", "related_websites". Do not leave any out.
                - If you can't find information for a specific field, fill in the information with the word "MISSING".
                - Do not generate fake information. Only return the information you find. Nothing else!

> Entering new CrewAgentExecutor chain...

Action: Search the internet

Action Input: {
    "search_query": "popular children's books for kids 

Search results: Title: Children's Books - Amazon Best Sellers
Link: https://www.amazon.com/Best-Sellers-Children's-Books/zgbs/books/4
Snippet: Discover the best books in Amazon Best Sellers. Find the top 100 most popular Amazon books.
---
Title: Best Kids Books | Popular Children's Books | Barnes & Noble®
Link: https://www.barnesandnoble.com/b/books/kids/_/N-29Z8q8Ztu1
Snippet: 10 of the Best Books for Kids to Read Right Now · Skandar and the Unicorn Thief by A.F. · The Three Billy Goats Gruff by Mac Barnett · Stellarlune by Shannon ...
---
Title: Best Children's Books (5105 books) - Goodreads
Link: https://www.goodreads.com/list/show/86.Best_Children_s_Books
Snippet: Best Children's Books · 1. Where the Wild Things Are · 2. The Very Hungry Caterpillar · 3. The Giving Tree · 4. Green Eggs and Ham · 5. Goodnight Moon · 6.
---
Title: 125 Books We Love for Kids | The New York Public Library
Link: https://www.nypl.org/books-more/recommendations/125/kids
Snippet: 125 Books Found. The Adventures of Captain Underpants. By Dav Pilkey. Book. Two friends hypnotize their principal and ...
---
Title: Best Sellers: Children's Books - Penguin Random House
Link: https://www.penguinrandomhouse.com/books/best-sellers-childrens/
Snippet: Best Sellers: Children's Books. 1083 Results. The Truth About the Couch · Adam Rubin · Magnolia Wu Unfolds It All · Chanel Miller · My Lost Freedom.
---
Title: Welcome To Story Hour: 100 Favorite Books For Young Readers
Link: https://www.npr.org/2020/08/31/905804301/welcome-to-story-hour-100-favorite-books-for-young-readers
Snippet: Frog and Toad (series). Frog and Toad Are Friends · “Frog and Toad are Friends” ; Little Bear (series). Little Bear · “Little Bear” ; Anna Hibiscus ...
---
Title: Your favorite Children's books? : r/suggestmeabook - Reddit
Link: https://www.reddit.com/r/suggestmeabook/comments/17o1jxn/your_favorite_childrens_books/
Snippet: “Little Witch Hazel” and “Sonya's Chickens” by Phoebe Wahl. “Invisible Things” by Andy J. Pizza. “Boot and Shoe” by Marla Frazee. “ALFIE” and “ ...
---
Title: Top 100 Children's Picturebooks of All-Time - Scottsdale Public Library
Link: https://www.scottsdalelibrary.org/youth/100-best-picturebooks
Snippet: Choosing a variety of well written, colorful, and entertaining stories from some of the best children's books ever will help develop a love of reading and a ...
---
Title: Teacher Picks: Top 25 Picture Books - Scholastic
Link: https://www.scholastic.com/teachers/teaching-tools/book-lists/teacher-picks--top-25-picture-books.html
Snippet: Where the Wild Things Are, The Snowy Day, Corduroy, and Clifford the Big Red Dog are just a few of the beloved classic picture books featured in ...
---
Title: 50 Books All Kids Should Read Before They're 12
Link: https://www.commonsensemedia.org/lists/50-books-all-kids-should-read-before-theyre-12
Snippet: Don't Let the Pigeon Drive the Bus! · Goodnight, Goodnight, Construction Site · Goodnight Moon · The Snowy Day · The Very Hungry Caterpillar · Where the Wild Things ...
---

^CTraceback (most recent call last):
  File "/home/felixgao/projects/cosette/crew.py", line 94, in <module>
    crew.crew.kickoff()
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/crew.py", line 264, in kickoff
    result = self._run_sequential_process()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/crew.py", line 305, in _run_sequential_process
    output = task.execute(context=task_output)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/task.py", line 183, in execute
    result = self._execute(
             ^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/task.py", line 192, in _execute
    result = agent.execute_task(
             ^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/agent.py", line 236, in execute_task
    result = self.agent_executor.invoke(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain/chains/base.py", line 163, in invoke
    raise e
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain/chains/base.py", line 153, in invoke
    self._call(inputs, run_manager=run_manager)
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/agents/executor.py", line 128, in _call
    next_step_output = self._take_next_step(
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain/agents/agent.py", line 1138, in _take_next_step
    [
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/crewai/agents/executor.py", line 192, in _iter_next_step
    output = self.agent.plan(  # type: ignore #  Incompatible types in assignment (expression has type "AgentAction | AgentFinish | list[AgentAction]", variable has type "AgentAction")
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain/agents/agent.py", line 397, in plan
    for chunk in self.runnable.stream(inputs, config={"callbacks": callbacks}):
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 2875, in stream
    yield from self.transform(iter([input]), config, **kwargs)
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 2862, in transform
    yield from self._transform_stream_with_config(
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1881, in _transform_stream_with_config
    chunk: Output = context.run(next, iterator)  # type: ignore
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 2826, in _transform
    for output in final_pipeline:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1282, in transform
    for ichunk in input:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 4736, in transform
    yield from self.bound.transform(
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/runnables/base.py", line 1300, in transform
    yield from self.stream(final, config, **kwargs)
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 249, in stream
    raise e
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_core/language_models/chat_models.py", line 229, in stream
    for chunk in self._stream(messages, stop=stop, **kwargs):
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/langchain_openai/chat_models/base.py", line 408, in _stream
    for chunk in self.client.create(messages=message_dicts, **params):
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/openai/_streaming.py", line 46, in __iter__
    for item in self._iterator:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/openai/_streaming.py", line 58, in __stream__
    for sse in iterator:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/openai/_streaming.py", line 50, in _iter_events
    yield from self._decoder.iter_bytes(self.response.iter_bytes())
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/openai/_streaming.py", line 280, in iter_bytes
    for chunk in self._iter_chunks(iterator):
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/openai/_streaming.py", line 291, in _iter_chunks
    for chunk in iterator:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpx/_models.py", line 829, in iter_bytes
    for raw_bytes in self.iter_raw():
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpx/_models.py", line 883, in iter_raw
    for raw_stream_bytes in self.stream:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpx/_client.py", line 126, in __iter__
    for chunk in self._stream:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 113, in __iter__
    for part in self._httpcore_stream:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 367, in __iter__
    raise exc from None
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 363, in __iter__
    for part in self._stream:
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 349, in __iter__
    raise exc
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 341, in __iter__
    for chunk in self._connection._receive_response_body(**kwargs):
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 210, in _receive_response_body
    event = self._receive_event(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_sync/http11.py", line 224, in _receive_event
    data = self._network_stream.read(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/felixgao/projects/cosette/.venv/lib/python3.12/site-packages/httpcore/_backends/sync.py", line 126, in read
    return self._sock.recv(max_bytes)
           ^^^^^^^^^^^^^^^^^^^^^^

The code is fairly simple.


    def story_research_agent(self, )-> Agent:
        return Agent(
            role="Story Researcher",
            goal="""Research and compile information on popular children's books, including summaries, author biographies, and reviews.
            Provide a curated list of recommended children's books based on various themes, age groups, and genres. 
            Additionally, gather resources such as educational activities, discussion guides, and related websites to supplement the reading experience. 
            Present the findings in JSON format.

            Important:
                - Limit the number of results to 10.
                - The final list of JSON object must includes the following fields: "title", "author", "genre", "summary", "age_groups", "reviews", "educational_activities", "discussion_guides", "related_websites".  Do not leave any out.
                - If you can't find information for a specific position, fill in the information with the word "MISSING".
                - Do not generate fake information. Only return the information you find. Nothing else!
            """, # TODO: provide the JSON schema for what the research agent should return.
            backstory="""With decades of experience in the industry, you have a deep understanding of what elements make a children's book truly memorable. 
            Your expertise lies in identifying the key components that resonate with young audiences, fostering their imagination, and leaving a lasting impact.

            Important:
                - Once you've found the information, immediately stop searching for additional information.
                - Only return the requested information. NOTHING ELSE!
            """,
            llm=self.llms["llama3"],
            tools=[self.search_internet_tool], # Should also have youtube search tool
            verbose=True,
        )

    def research_stories(self, story_research_agent: Agent):
        return Task(
            description=dedent("""Research and compile information on popular children's books, including summaries, author biographies, and reviews.
            Provide a curated list of recommended children's books based on various themes, age groups, and genres.
            Additionally, gather resources such as educational activities, discussion guides, and related websites to supplement the reading experience.
            Present the findings in JSON format.

            Important:
                - Limit the number of results to 10.
                - The final list of JSON objects must include the following fields: "title", "author", "genre", "summary", "age_groups", "reviews", "educational_activities", "discussion_guides", "related_websites". Do not leave any out.
                - If you can't find information for a specific field, fill in the information with the word "MISSING".
                - Do not generate fake information. Only return the information you find. Nothing else!
            """),
            agent=story_research_agent,
            expected_output=dedent("""A list of JSON objects containing the requested information for a curated selection of children's books."""),
            callback=self.append_event_callback,
            output_pydantic=StoryResearchResults,
            async_execution=False, # Currently a bug when turned on https://github.com/joaomdmoura/crewAI/issues/285
        )

        story_research_agent = agents.story_research_agent()
        research_stories_task = tasks.research_stories(story_research_agent)

        crew = Crew(
            agents=[story_research_agent],
            tasks=[research_stories_task],
            verbose=2,
            process=Process.sequential
        )
gadgethome commented 3 months ago

Please can you upload your full code as well as the tools used search_internet_tool so we can run and test it. Thanks

github-actions[bot] commented 2 weeks ago

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.

github-actions[bot] commented 1 week ago

This issue was closed because it has been stalled for 5 days with no activity.