diff --git a/samples/apps/autogen-studio/autogenstudio/workflowmanager.py b/samples/apps/autogen-studio/autogenstudio/workflowmanager.py index a28bc9a7dd34..1d5939f18543 100644 --- a/samples/apps/autogen-studio/autogenstudio/workflowmanager.py +++ b/samples/apps/autogen-studio/autogenstudio/workflowmanager.py @@ -102,7 +102,8 @@ def sanitize_agent_spec(self, agent_spec: AgentFlowSpec) -> AgentFlowSpec: """ agent_spec.config.is_termination_msg = agent_spec.config.is_termination_msg or ( - lambda x: "TERMINATE" in x.get("content", "").rstrip() + lambda x: x.get("content", "") + and "TERMINATE" in x.get("content", "").rstrip() ) skills_prompt = "" if agent_spec.skills: @@ -139,10 +140,18 @@ def load(self, agent_spec: AgentFlowSpec) -> autogen.Agent: agent_spec = self.sanitize_agent_spec(agent_spec) if agent_spec.type == "assistant": agent = autogen.AssistantAgent(**asdict(agent_spec.config)) - agent.register_reply([autogen.Agent, None], reply_func=self.process_reply, config={"callback": None}) + agent.register_reply( + [autogen.Agent, None], + reply_func=self.process_reply, + config={"callback": None}, + ) elif agent_spec.type == "userproxy": agent = autogen.UserProxyAgent(**asdict(agent_spec.config)) - agent.register_reply([autogen.Agent, None], reply_func=self.process_reply, config={"callback": None}) + agent.register_reply( + [autogen.Agent, None], + reply_func=self.process_reply, + config={"callback": None}, + ) else: raise ValueError(f"Unknown agent type: {agent_spec.type}") return agent