autogen forward input to another agent (register_reply??)

552 Views Asked by At

I'm having a scenario where I need to develop a solution which the one agent will comeup with a plan and then goes a review cycle with the user, before forward it into a group of other agents. I have my human_input_mode set to ALWAYS on the user_proxy but not sure how to sort forward the conversation automatically once the user agrees with the plan.

I tried to use register_reply but for whatever reason this doesn't work on my approach. (I think I'm doing something silly)

project_manager = autogen.AssistantAgent(
    name="project_manager",
    system_message="""You are responsible for coming up with a plan to estimate the cost.""",
    llm_config=llm_config,
)

comedian = autogen.AssistantAgent(
    name= "comedian",
    system_message="""Your job is to make a joke about the plan shared.
    """,
    llm_config=llm_config,)

user_proxy = autogen.UserProxyAgent(
   name="User_proxy",
   system_message="A human admin.",
   code_execution_config={"last_n_messages": 2, "work_dir": "groupchat"},
   human_input_mode="ALWAYS",
   function_map={"ask_planner": ask_planner},
)

project_manager.register_reply(user_proxy,add_data_reply)

async def add_data_reply(recipient, messages, sender, config):
    print("HERE")
    print("messages:" + str(messages))
    comedian.generate_reply(messages=messages)



user_proxy.initiate_chat(
    project_manager,
    message="""I would like you to comeup with a plan to build a model rocket""", 
)

1

There are 1 best solutions below

0
On

I believe register_reply() is used when you want to control how an agent replies.

There are a couple of other ways you can control conversation flow:

  • Override GroupChat to construct a custom class where you have full control over the next speaker (see this notebook)
  • Convert agents into a tool / function. This way, top-level agents can control when the other agents are invoked. (see this notebook)