Skip to content

Commit

Permalink
fix: remove exception handling and retry mechanism in peer agents
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinInAu committed Jul 8, 2024
1 parent b335716 commit ae62e1e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 35 deletions.
41 changes: 7 additions & 34 deletions agentuniverse/agent/plan/planner/peer_planner/peer_planner.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,15 @@ def agents_run(self, agents: dict, planner_config: dict, agent_input: dict, inpu
expressingAgent = agents.get('expressing')
reviewingAgent = agents.get('reviewing')

for i in range(retry_count):
LOGGER.info(f"Starting peer agents, retry_count is {i + 1}.")
for _ in range(retry_count):
LOGGER.info(f"Starting peer agents, retry_count is {_ + 1}.")
if not planning_result or jump_step == "planning":
if not planningAgent:
LOGGER.warn("no planning agent.")
planning_result = OutputObject({"framework": [agent_input.get('input')]})
else:
LOGGER.info(f"Starting planning agent.")
try:
planning_result = planningAgent.run(**input_object.to_dict())
except Exception as e:
LOGGER.error(f"Exception occurred during the planning agent's invocation, exception: {e}")
if i >= retry_count - 1:
raise e
else:
continue
planning_result = planningAgent.run(**input_object.to_dict())

input_object.add_data('planning_result', planning_result)
# add planning agent log info
Expand All @@ -139,14 +132,7 @@ def agents_run(self, agents: dict, planner_config: dict, agent_input: dict, inpu
executing_result = OutputObject({})
else:
LOGGER.info(f"Starting executing agent.")
try:
executing_result = executingAgent.run(**input_object.to_dict())
except Exception as e:
LOGGER.error(f"Exception occurred during the executing agent's invocation, exception: {e}")
if i >= retry_count - 1:
raise e
else:
continue
executing_result = executingAgent.run(**input_object.to_dict())

input_object.add_data('executing_result', executing_result)
# add executing agent log info
Expand All @@ -164,14 +150,7 @@ def agents_run(self, agents: dict, planner_config: dict, agent_input: dict, inpu
expressing_result = OutputObject({})
else:
LOGGER.info(f"Starting expressing agent.")
try:
expressing_result = expressingAgent.run(**input_object.to_dict())
except Exception as e:
LOGGER.error(f"Exception occurred during the expressing agent's invocation, exception: {e}")
if i >= retry_count - 1:
raise e
else:
continue
expressing_result = expressingAgent.run(**input_object.to_dict())

input_object.add_data('expressing_result', expressing_result)
# add expressing agent log info
Expand All @@ -192,14 +171,8 @@ def agents_run(self, agents: dict, planner_config: dict, agent_input: dict, inpu
return result
else:
LOGGER.info(f"Starting reviewing agent.")
try:
reviewing_result = reviewingAgent.run(**input_object.to_dict())
except Exception as e:
LOGGER.error(f"Exception occurred during the reviewing agent's invocation, exception: {e}")
if i >= retry_count - 1:
raise e
else:
continue
reviewing_result = reviewingAgent.run(**input_object.to_dict())

input_object.add_data('reviewing_result', reviewing_result)

# add reviewing agent log info
Expand Down
2 changes: 1 addition & 1 deletion agentuniverse/base/component/component_manager_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def unregister(self, component_instance_name: str):
self._instance_obj_map.pop(component_instance_name)

def get_instance_obj(self, component_instance_name: str,
appname: str = None, new_instance: bool = None) -> ComponentTypeVar:
appname: str = None, new_instance: bool = False) -> ComponentTypeVar:
"""Return the component instance object."""
appname = appname or ApplicationConfigManager().app_configer.base_info_appname
instance_code = f'{appname}.{self._component_type.value.lower()}.{component_instance_name}'
Expand Down

0 comments on commit ae62e1e

Please sign in to comment.