Basic Environment Settings

OASIS provides a powerful simulation environment for social media platforms. This guide covers the basic configuration options for setting up your simulation environment.

Environment Initialization

To create a simulation environment, use the make function from OASIS:

import oasis
from oasis import DefaultPlatformType

env = oasis.make(
    platform=DefaultPlatformType.TWITTER,  # or DefaultPlatformType.REDDIT
    database_path="./data/simulation.db",
    agent_profile_path="./data/profiles/users.csv",
    agent_models=models,
    available_actions=available_actions,
)

Core Environment Parameters

When initializing the OASIS environment, you can configure the following core parameters:

ParameterTypeDescription
platformDefaultPlatformType or PlatformThe platform type to use (TWITTER or REDDIT) or a custom Platform instance
database_pathstrPath to create a SQLite database (must end with .db)
agent_profile_pathstrPath to agent profiles data
agent_modelsBaseModelBackend or List[BaseModelBackend]Model backend(s) for agent responses
available_actionslist[ActionType]List of allowed actions for agents
semaphoreintLimit on concurrent LLM requests (default: 128)

For more details, see the Platform, Agent Profile, Model and Actions Module.

Environment Lifecycle

The OASIS environment has a simple lifecycle you can manage with these methods:

# Initialize the environment
await env.reset()

# Run simulation steps
for _ in range(n):
    await env.step(env_actions)

# Close the environment when done
await env.close()

Environment Actions

The environment update through the step method, which uses EnvAction. EnvAction includes a list of activated agent IDs and predefined SingleAction interventions. During the step, interventions are applied, the recommendation system cache is refreshed, and activated agents perform actions based on LLMs.

from oasis import EnvAction, SingleAction, ActionType

# Create an action for a specific agent
action = SingleAction(
    agent_id=0,
    action=ActionType.CREATE_POST,
    args={"content": "Hello, OASIS world!"}
)

# Create an environment action to activate agents and include interventions
env_action = EnvAction(
    activate_agents=[0, 1, 2, 3],  # List of agent IDs to activate
    intervention=[action]  # List of interventions
)

# Step the environment with the action
await env.step(env_action)

For more action details, see Actions Module