Error parsing LLM output, agent will retry: I did it wrong. Tried to both perform Action and give a Final Answer at the same time, I must do one or the other

I keep getting this error from crewAI and after which the generation of the output is bad. This is with Ollama : mistral or Mistral-Nemo, Llama3.2

@albert_pinto There can be two reasons:

  • Such errors can happen because of the LLM you’re using. Unfortunately, smaller LLMs sometimes struggle to work with CrewAI (source). Try to switch the LLM to a more capable one.
  • Such errors can happen because the task prompt is too long or strong, which changes some internal CrewAI keywords like action, thought, etc (source). Try to adjust the task prompt.

Thank you for your response. Appreciate it!
The issue is with Llama3.2, it works with Llama3.

@rokbenko is there any way i can set handle_parsing_error=True in crewai

I also have a similar problem with gpt-4o-mini

I did it wrong. Invalid Format: I missed the ‘Action:’ after ‘Thought:’. I will do right next, and don’t use a tool I have already used. If you don’t need to use any more tools, you must give your best complete final answer, make sure it satisfy the expect criteria, use the EXACT format below: Thought: I now can give a great answer Final Answer: my best complete final answer to the task.

1 Like

Since you’re already using a highly capable LLM (i.e., gpt-4o-mini), it’s likely that the second reason is the cause. See my answer above.

Im following the documentation as in the link below and getting the same error. any guidance on how the tasks prompt can be adjusted to align with crewai will be greatly apprecaited:

tasks file from the master crewai course