LiteLLM: Crew stuck in Loop

When I kick off a crew, it gets stuck in a loop. Is there any parameter I can use to avoid the loop?
If the problem is my OpenAI API Key then this should definitely stop after some retries, but my crew does not.

llm = LLM(
    model='gpt-4o-mini',
    api_key=OPENAI_API_KEY
    )

Agent setting:

-  allow_delegation=True,
-  verbose=True,
-  max_iter=3,

Stuck in Loop

  • ERROR:root:LiteLLM call failed: litellm.AuthenticationError: AuthenticationError: OpenAIException - Error code: 401 - {‘error’: {‘message’: ‘Incorrect API key provided: sk-proj-*********************************************. You can find your API key at https://platform.openai.com/account/api-keys.’, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘invalid_api_key’}}

  • LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True’.

.
.
.

2 Likes

I faced on same issue.
I’m using ollama as below.

llm=LLM(model="ollama/llama3.1", base_url="http://localhost:11434")

	@crew
	def crew(self) -> Crew:
		return Crew(
			agents=self.agents,
			tasks=self.tasks,
			process=Process.sequential,
			verbose=True,
			model="ollama/llama3.1",
			chat_llm=llm
		)

I’m struck in similar situation. Instead of llm=LLM(…), I am using llma=Ollama(…) as calling LLM was giving an error. No error on execution but goes in loop even though I’ve given max_iterations and max_time. Any help will be appreciated as cannot run open source on local laptop

Which model are you using with Ollama? I’ve seen weaker models often go into loops and just perform badly. Test with gpt-4o to see if the problem persists

Well, it’s actually gpt-4o.

Same problem. Does anyone find the solution for this?