diff --git a/dbgpt/serve/agent/team/layout/agent_operator.py b/dbgpt/serve/agent/team/layout/agent_operator.py index 9cdac9d98..b7d401717 100644 --- a/dbgpt/serve/agent/team/layout/agent_operator.py +++ b/dbgpt/serve/agent/team/layout/agent_operator.py @@ -135,22 +135,30 @@ async def map( self, input_value: AgentGenerateContext, ) -> AgentGenerateContext: - now_rely_messages: List[Dict] = [] - + now_message = input_value.message agent = await self.get_agent(input_value) + if agent.fixed_subgoal and len(agent.fixed_subgoal) > 0: + # Isolate the message delivery mechanism and pass it to the operator + input_value.message["current_gogal"] = ( + f"[{agent.name if agent.name else agent.profile}]:" + + agent.fixed_subgoal + ) + now_message["content"] = agent.fixed_subgoal + else: + # Isolate the message delivery mechanism and pass it to the operator + input_value.message["current_gogal"] = ( + f"[{agent.name if agent.name else agent.profile}]:" + + input_value.message["content"] + ) - # Isolate the message delivery mechanism and pass it to the operator - input_value.message["current_gogal"] = ( - f"[{agent.name if agent.name else agent.profile}]:" - + input_value.message["content"] - ) + now_rely_messages: List[Dict] = [] ###What was received was the User message human_message = input_value.message.copy() human_message["role"] = ModelMessageRoleType.HUMAN now_rely_messages.append(human_message) ###Send a message (no reply required) and pass the message content - now_message = input_value.message + if input_value.rely_messages and len(input_value.rely_messages) > 0: now_message = input_value.rely_messages[-1] await input_value.sender.a_send(now_message, agent, input_value.reviewer, False) @@ -200,9 +208,13 @@ async def get_agent( llm_config = LLMConfig(llm_client=input_value.llm_client) else: llm_config = LLMConfig(llm_client=self.llm_client) - + kwargs = {} + if self.awel_agent.role_name: + kwargs["name"] = self.awel_agent.role_name + if self.awel_agent.fixed_subgoal: + kwargs["fixed_subgoal"] = self.awel_agent.fixed_subgoal agent = ( - await agent_cls(name=self.awel_agent.role_name) + await agent_cls(**kwargs) .bind(input_value.memory) .bind(llm_config) .bind(input_value.agent_context) diff --git a/dbgpt/serve/agent/team/layout/agent_operator_resource.py b/dbgpt/serve/agent/team/layout/agent_operator_resource.py index a30b450a8..3f571b585 100644 --- a/dbgpt/serve/agent/team/layout/agent_operator_resource.py +++ b/dbgpt/serve/agent/team/layout/agent_operator_resource.py @@ -139,6 +139,14 @@ def pre_fill(cls, values: Dict[str, Any]) -> Dict[str, Any]: default=None, description="The agent role name.", ), + Parameter.build_from( + label="Fixed Gogal", + name="fixed_subgoal", + type=str, + optional=True, + default=None, + description="The agent fixed gogal.", + ), Parameter.build_from( label="Agent Resource", name="agent_resource", @@ -162,6 +170,7 @@ class AwelAgent(BaseModel): role_name: Optional[str] = None llm_config: Optional[LLMConfig] = None resources: List[AgentResource] = Field(default_factory=list) + fixed_subgoal: Optional[str] = None class Config: arbitrary_types_allowed = True diff --git a/dbgpt/serve/agent/team/plan/team_auto_plan.py b/dbgpt/serve/agent/team/plan/team_auto_plan.py index 2e2c3e9cc..175a3efbe 100644 --- a/dbgpt/serve/agent/team/plan/team_auto_plan.py +++ b/dbgpt/serve/agent/team/plan/team_auto_plan.py @@ -117,6 +117,7 @@ async def a_act( reviewer: Optional[ConversableAgent] = None, ) -> Optional[ActionOutput]: speaker = sender + final_message = message for i in range(self.max_round): plans = self.memory.plans_memory.get_by_conv_id(self.agent_context.conv_id) @@ -153,7 +154,7 @@ async def a_act( # complete return ActionOutput( is_exe_success=True, - content=f"{plans[-1].result}", # work results message + content=final_message, # work results message ) else: try: @@ -201,11 +202,14 @@ async def a_act( ) plan_result = "" + final_message = reply_message["content"] if is_success: if reply_message: action_report = reply_message.get("action_report", None) if action_report: plan_result = action_report.get("content", "") + final_message = action_report["view"] + ### The current planned Agent generation verification is successful ##Plan executed successfully self.memory.plans_memory.complete_task( @@ -213,7 +217,6 @@ async def a_act( now_plan.sub_task_num, plan_result, ) - else: plan_result = reply_message["content"] self.memory.plans_memory.update_task( @@ -228,6 +231,7 @@ async def a_act( return ActionOutput( is_exe_success=False, content=plan_result ) + except Exception as e: logger.exception( f"An exception was encountered during the execution of the current plan step.{str(e)}"