crewAIInc / crewAI-examples

2.63k stars 981 forks source link

How to increase the reliability of the crewai-langgraph example #47

Closed herveleclerc closed 1 week ago

herveleclerc commented 7 months ago

Hello

sometimes the example crashes even if we have the same emails to process on the test sets. The thread_id is not passed correctly to the google api. For example:

> Entering new CrewAgentExecutor chain...
Thought: Do I need to use a tool? Yes
Action: get_gmail_thread
Action Input: thread_id:18cc96304f1566d0Traceback (most recent call last):
  File "/Users/hleclerc/dev/projects/clients/alterway/alterwai/crewAI-examples/CrewAI-LangGraph/main.py", line 4, in <module>
    app.invoke({})
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 569, in invoke
    for chunk in self.stream(
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 605, in transform
    for chunk in self._transform_stream_with_config(
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1497, in _transform_stream_with_config
    chunk: Output = context.run(next, iterator)  # type: ignore
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 347, in _transform
    _interrupt_or_proceed(done, inflight, step)
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langgraph/pregel/__init__.py", line 688, in _interrupt_or_proceed
    raise exc
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 4041, in invoke
    return self.bound.invoke(
           ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 2053, in invoke
    input = step.invoke(
            ^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 3507, in invoke
    return self._call_with_config(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 1246, in _call_with_config
    context.run(
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 326, in call_func_with_variable_args
    return func(input, **kwargs)  # type: ignore[call-arg]
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/base.py", line 3383, in _invoke
    output = call_func_with_variable_args(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/runnables/config.py", line 326, in call_func_with_variable_args
    return func(input, **kwargs)  # type: ignore[call-arg]
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hleclerc/dev/projects/clients/alterway/alterwai/crewAI-examples/CrewAI-LangGraph/src/crew/crew.py", line 25, in kickoff
    result = crew.kickoff()
             ^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/crewai/crew.py", line 127, in kickoff
    return self._sequential_loop()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/crewai/crew.py", line 134, in _sequential_loop
    task_output = task.execute(task_output)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/crewai/task.py", line 56, in execute
    result = self.agent.execute_task(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/crewai/agent.py", line 146, in execute_task
    result = self.agent_executor.invoke(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain/chains/base.py", line 162, in invoke
    raise e
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain/chains/base.py", line 156, in invoke
    self._call(inputs, run_manager=run_manager)
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/crewai/agents/executor.py", line 59, in _call
    next_step_output = self._take_next_step(
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain/agents/agent.py", line 1097, in _take_next_step
    [
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain/agents/agent.py", line 1097, in <listcomp>
    [
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/crewai/agents/executor.py", line 191, in _iter_next_step
    observation = tool.run(
                  ^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/tools.py", line 373, in run
    raise e
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_core/tools.py", line 345, in run
    self._run(*tool_args, run_manager=run_manager, **tool_kwargs)
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/langchain_community/tools/gmail/get_thread.py", line 37, in _run
    thread_data = query.execute()
                  ^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/googleapiclient/_helpers.py", line 130, in positional_wrapper
    return wrapped(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/anaconda3/envs/crewai-example/lib/python3.11/site-packages/googleapiclient/http.py", line 938, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://gmail.googleapis.com/gmail/v1/users/me/threads/thread_id%3A18cc90303f1526d0?alt=json returned "Invalid id value". Details: "[{'message': 'Invalid id value', 'domain': 'global', 'reason': 'invalidArgument'}]">

as you can see the url is not correct

we should have

I 've tried to change the Task prompt with thread_id (ONLY the id of the thread_id)

it's better but not every time

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 stale for 5 days with no activity.