Find answers from the community

Updated 8 months ago

ReAct Agent Evaulation

ReAct Agent Evaulation

I am following the below guides. I am first setting up the top_agent and then trying to build a rag_dataset with it. The problem is that it gets to a certain point and then gives me the below error message. Any ideas on how to resolve?

https://docs.llamaindex.ai/en/stable/examples/agent/multi_document_agents/
https://docs.llamaindex.ai/en/stable/examples/evaluation/answer_and_context_relevancy/


---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[17], line 1
----> 1 prediction_dataset = await qas.amake_predictions_with(
2 predictor=top_agent, batch_size=100, show_progress=True
3 )

File ~/anaconda3/envs/nat_gpu/lib/python3.11/site-packages/llama_index/core/agent/react/step.py:583, in ReActAgentWorker._arun_step(self, step, task)
579 reasoning_steps, is_done = await self._aprocess_actions(
580 task, tools, output=chat_response
581 )
582 task.extra_state["current_reasoning"].extend(reasoning_steps)
--> 583 agent_response = self._get_response(
584 task.extra_state["current_reasoning"], task.extra_state["sources"]
585 )
586 if is_done:
587 task.extra_state["new_memory"].put(
588 ChatMessage(content=agent_response.response, role=MessageRole.ASSISTANT)
589 )

File ~/anaconda3/envs/nat_gpu/lib/python3.11/site-packages/llama_index/core/agent/react/step.py:413, in ReActAgentWorker._get_response(self, current_reasoning, sources)
411 raise ValueError("No reasoning steps were taken.")
412 elif len(current_reasoning) == self._max_iterations:
--> 413 raise ValueError("Reached max iterations.")
415 if isinstance(current_reasoning[-1], ResponseReasoningStep):
416 response_step = cast(ResponseReasoningStep, current_reasoning[-1])

ValueError: Reached max iterations.
L
g
7 comments
you can increase max_iterations on the agent
ReActAgent.from_tools(..., max_iterations=10)

Default is 5
Okay, I’ll give it a shot. I thought it would just stop and say it can’t answer the question? I’ll take another look into it. Thank you as always. You all rock.
@Logan M changed to 10 - same issue. I’ll try again with 20 but just reaching out if you had any other ideas?
Nope 🤷‍♂️ My only other guesss is wrap the agent with a try/except function
I'm guess some question is causing it to go a little wild
Sounds good. Thanks!
Add a reply
Sign up and join the conversation on Discord