Skip to content

Commit

Permalink
Ensure attribute existence before accessing in AgentExecutor initiali…
Browse files Browse the repository at this point in the history
…zation
  • Loading branch information
ogabrielluiz committed Nov 18, 2024
1 parent d219fb0 commit b0b6dc0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/backend/base/langflow/base/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,18 @@ async def run_agent(
if isinstance(agent, AgentExecutor):
runnable = agent
else:
if not self.tools:
if not hasattr(self, "tools") or not self.tools:
msg = "Tools are required to run the agent."
raise ValueError(msg)
handle_parsing_errors = hasattr(self, "handle_parsing_errors") and self.handle_parsing_errors
verbose = hasattr(self, "verbose") and self.verbose
max_iterations = hasattr(self, "max_iterations") and self.max_iterations
runnable = AgentExecutor.from_agent_and_tools(
agent=agent,
tools=self.tools,
handle_parsing_errors=self.handle_parsing_errors,
verbose=self.verbose,
max_iterations=self.max_iterations,
handle_parsing_errors=handle_parsing_errors,
verbose=verbose,
max_iterations=max_iterations,
)
input_dict: dict[str, str | list[BaseMessage]] = {"input": self.input_value}
if hasattr(self, "chat_history") and self.chat_history:
Expand Down

0 comments on commit b0b6dc0

Please sign in to comment.