fix: handle None agent_executor and type mismatch

- Add None check before accessing agent_executor attributes
- Convert task.human_input to bool for type compatibility
This commit is contained in:
Greyson LaLonde
2025-07-22 10:21:31 -04:00
parent 767bbd693d
commit a893e6030b

View File

@@ -547,12 +547,17 @@ class Agent(BaseAgent):
Returns:
The output of the agent.
"""
if not self.agent_executor:
raise ValueError(
"Agent executor not initialized. Call create_agent_executor() first."
)
return self.agent_executor.invoke(
{
"input": task_prompt,
"tool_names": self.agent_executor.tools_names,
"tools": self.agent_executor.tools_description,
"ask_for_human_input": task.human_input,
"ask_for_human_input": bool(task.human_input),
}
)["output"]