sotopia-lab / sotopia

Sotopia: an Open-ended Social Learning Environment (ICLR 2024 spotlight)
https://docs.sotopia.world
MIT License
127 stars 16 forks source link

[BUG]: Reinitialized agents #84

Open XuhuiZhou opened 1 month ago

XuhuiZhou commented 1 month ago

Description of the bug

The agents have been reinitialized here, which is a problematic behavior since the agents have been initialized before:

https://github.com/sotopia-lab/sotopia/blob/184d1ca84e03c549bab05d2b8b530d65b1c75a14/sotopia/server.py#L119

Steps To Reproduce

Just need to look at it

Additional Information

No response

XuhuiZhou commented 1 month ago

@ProKil

I am proposing removing these lines:

    agents_model_names = [model_dict["agent1"], model_dict["agent2"]]
    for agent_name, agent_model in zip(env.agents, agents_model_names):
        if agent_model == "human":
            agents[agent_name] = HumanAgent(agent_name)
        elif agent_model == "redis":
            agents[agent_name] = RedisAgent(agent_name)
        elif script_like and not json_in_script:
            agents[agent_name] = ScriptWritingAgent(
                agent_name,
                model_name=agent_model,
                background=env.background,
                agent_names=env.agents,
            )
        else:
            agents[agent_name] = LLMAgent(
                agent_name, model_name=agent_model, script_like=script_like
            )
ProKil commented 1 month ago

Yes.

More generally, we can modularize the server behavior:

  1. EnvironmentAgentCombo comes with initialized agents and environments, which will not be initialized for the second time in the server,
  2. A static class method EnvironmentAgentCombo.new() returns a new EnvironmentAgentCombo which takes a configuration object as input and initialize the agents and the environment.
XuhuiZhou commented 1 month ago

Not sure if I understand the 2 point. But here's the branch for the purpose of making Sotopia more organic for other applications. https://github.com/sotopia-lab/sotopia/pull/86

ProKil commented 1 week ago

Has this already been solved in #69 ?