Skip to content

Commit 54d911c

Browse files
zhiweizhiwei
authored andcommitted
fix some bugs
1 parent 86cc7fb commit 54d911c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/agent/agent.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ def create_agent():
5151
raise ValueError(f"Tool ID '{tool_id}' is not registered.")
5252
tools.append(REGISTED_TOOLS[tool_id]())
5353

54-
tools = tools + sub_agent_tools
55-
54+
#tools = tools + sub_agent_tools
55+
5656
agent = REGISTED_AGENTS["planning_agent"](
5757
config=planning_agent_config,
5858
model=model_manager.registed_models[planning_agent_config.model_id],
5959
tools=tools,
6060
max_steps=planning_agent_config.max_steps,
61+
managed_agents=sub_agents,
6162
description=planning_agent_config.description,
6263
name=planning_agent_config.name,
6364
provide_run_summary=True,

src/base/async_multistep_agent.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ async def _run(
380380
self.step_number += 1
381381

382382
if final_answer is None and self.step_number == max_steps + 1:
383-
final_answer = self._handle_max_steps_reached(task, images, step_start_time)
383+
final_answer = await self._handle_max_steps_reached(task, images, step_start_time)
384384
yield action_step
385385
yield FinalAnswerStep(final_answer)
386386

@@ -407,8 +407,8 @@ def _finalize_step(self, memory_step: ActionStep, step_start_time: float):
407407
memory_step, agent=self
408408
)
409409

410-
def _handle_max_steps_reached(self, task: str, images: list["PIL.Image.Image"], step_start_time: float) -> Any:
411-
final_answer = self.provide_final_answer(task, images)
410+
async def _handle_max_steps_reached(self, task: str, images: list["PIL.Image.Image"], step_start_time: float) -> Any:
411+
final_answer = await self.provide_final_answer(task, images)
412412
final_memory_step = ActionStep(
413413
step_number=self.step_number, error=AgentMaxStepsError("Reached max steps.", self.logger)
414414
)
@@ -577,7 +577,10 @@ async def provide_final_answer(self, task: str, images: list["PIL.Image.Image"]
577577
]
578578
if images:
579579
messages[0]["content"].append({"type": "image"})
580-
messages += await self.write_memory_to_messages()[1:]
580+
messages = await self.write_memory_to_messages()
581+
messages += messages[1:]
582+
583+
581584
messages += [
582585
{
583586
"role": MessageRole.USER,
@@ -592,7 +595,7 @@ async def provide_final_answer(self, task: str, images: list["PIL.Image.Image"]
592595
}
593596
]
594597
try:
595-
chat_message: ChatMessage = self.model(messages)
598+
chat_message: ChatMessage = await self.model(messages)
596599
return chat_message.content
597600
except Exception as e:
598601
return f"Error in generating final LLM output:\n{e}"

0 commit comments

Comments
 (0)