Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Ensure attribute existence before accessing in AgentExecutor initialization #4667

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/backend/base/langflow/base/agents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,21 @@ 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 self.chat_history:
if hasattr(self, "chat_history") and self.chat_history:
input_dict["chat_history"] = data_to_messages(self.chat_history)

if hasattr(self, "graph"):
Expand Down
Loading