diff --git a/swarms/agents/utils/AgentManager.py b/swarms/agents/utils/AgentManager.py index e392cfee..caa262a2 100644 --- a/swarms/agents/utils/AgentManager.py +++ b/swarms/agents/utils/AgentManager.py @@ -41,7 +41,6 @@ class AgentManager: builder = AgentBuilder(self.toolsets) builder.build_parser() - callbacks = [] eval_callback = EVALCallbackHandler() eval_callback.set_parser(builder.get_parser()) @@ -52,16 +51,16 @@ class AgentManager: execution_callback.set_parser(builder.get_parser()) callbacks.append(execution_callback) - #llm init callback_manager = CallbackManager(callbacks) builder.build_llm(callback_manager, openai_api_key) + if builder.llm is None: raise ValueError('LLM not created') builder.build_global_tools() - #agent init agent = builder.get_agent() + if not agent: raise ValueError("Agent not created") @@ -77,30 +76,19 @@ class AgentManager: for tool in tools: tool.callback_manager = callback_manager - # # Ensure the 'agent' key is present in the values dictionary - # values = {'agent': agent, 'tools': tools} - - # executor = AgentExecutor.from_agent_and_tools( - # agent=agent, - # tools=tools, - # memory=memory, - # callback_manager=callback_manager, - # verbose=True, - # ) - - # Prepare the arguments for the executor executor_args = { 'agent': agent, 'tools': tools, 'memory': memory, 'callback_manager': callback_manager, - 'verbose': True # Or any other value based on your requirement + 'verbose': True } executor = AgentExecutor.from_agent_and_tools(**executor_args) - if 'agent' not in executor.__dict__: - executor.__dict__['agent'] = agent + if not hasattr(executor, 'agent'): + raise ValueError("Executor does not have an 'agent' attribute") + self.executors[session] = executor return executor