fix(agent): allow agents to run without requiring any tools (#8533)

fix

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
Edwin Jose 2025-06-13 12:34:17 -05:00 • committed by GitHub
commit d5eef7a669
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 25 additions and 31 deletions

View file

@ -124,15 +124,13 @@ class LCAgentComponent(Component):
if isinstance(agent, AgentExecutor): if isinstance(agent, AgentExecutor):
runnable = agent runnable = agent
else: else:
if not hasattr(self, "tools") or not self.tools: # note the tools are not required to run the agent, hence the validation removed.
msg = "Tools are required to run the agent."
raise ValueError(msg)
handle_parsing_errors = hasattr(self, "handle_parsing_errors") and self.handle_parsing_errors handle_parsing_errors = hasattr(self, "handle_parsing_errors") and self.handle_parsing_errors
verbose = hasattr(self, "verbose") and self.verbose verbose = hasattr(self, "verbose") and self.verbose
max_iterations = hasattr(self, "max_iterations") and self.max_iterations max_iterations = hasattr(self, "max_iterations") and self.max_iterations
runnable = AgentExecutor.from_agent_and_tools( runnable = AgentExecutor.from_agent_and_tools(
agent=agent, agent=agent,
tools=self.tools, tools=self.tools or [],
handle_parsing_errors=handle_parsing_errors, handle_parsing_errors=handle_parsing_errors,
verbose=verbose, verbose=verbose,
max_iterations=max_iterations, max_iterations=max_iterations,

View file

@ -87,16 +87,12 @@ class AgentComponent(ToolCallingAgentComponent):
msg = "CurrentDateComponent must be converted to a StructuredTool" msg = "CurrentDateComponent must be converted to a StructuredTool"
raise TypeError(msg) raise TypeError(msg)
self.tools.append(current_date_tool) self.tools.append(current_date_tool)
# note the tools are not required to run the agent, hence the validation removed.
# Validate tools
if not self.tools:
msg = "Tools are required to run the agent. Please add at least one tool."
raise ValueError(msg)
# Set up and run agent # Set up and run agent
self.set( self.set(
llm=llm_model, llm=llm_model,
tools=self.tools, tools=self.tools or [],
chat_history=self.chat_history, chat_history=self.chat_history,
input_value=self.input_value, input_value=self.input_value,
system_prompt=self.system_prompt, system_prompt=self.system_prompt,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long