autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Add an agent to a team instance Dynamically

Open inspire-boy opened this issue 9 months ago • 0 comments

What is the doc issue?

I have build a SelectorGroupChat team in autogenStudio and export it.But there is a callback input function in UserProxyAgent that I don't find a way handle it. You can see my code

async def get_json_team(
    user_input_func: Callable[[str, Optional[CancellationToken]], Awaitable[str]],
) -> SelectorGroupChat:
    
    async with aiofiles.open('team-config.json', "r", encoding="utf-8") as file:
        team_json = await file.read()
    team_config = json.loads(team_json)
    team = BaseGroupChat.load_component(team_config)

    user_proxy = UserProxyAgent(
        name="user",
        input_func=user_input_func,  # Use the user input function.
    )
    ***team.agents.add(user_proxy)***
    return team

team.agents.add(user_proxy) is fake code. Is there a way to add an agent to the team Dynamically?

Link to the doc page, if applicable

https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/teams.html

inspire-boy avatar Apr 27 '25 18:04 inspire-boy