Actions for env.step

The actions parameter passed to the OASIS environment’s step method should be a dictionary that specifies what each agent should do at a given timestep, as shown below:

dict[SocialAgent, Union[List[Union[ManualAction, LLMAction]],Union[ManualAction, LLMAction]]]
  • The key is a SocialAgent.
  • The value is either:
    • A single predefined ManualAction or an LLM-generated LLMAction, or
    • A list of ManualAction or LLMAction instances, allowing the same agent to perform multiple actions within one timestep.

LLMAction

You can use LLMAction() to indicate that an agent should perform actions based on the output of an LLM. These actions can include both social actions and external tools, as defined during initialization.

An example where all agents use LLMAction() to perform actions:

from oasis import LLMAction

all_llm_actions = {
    agent: LLMAction()
    for _, agent in env.agent_graph.get_agents()
}

await env.step(all_llm_actions)

ManualAction

You can use ManualAction() to indicate that an agent should perform actions based on the predefined ActionType and corresponding arguments.

  • The data structure of ManualAction:
@dataclass
class ManualAction:
    r"""Some manual predefined social platform actions that need to be
    executed by certain agents.

    Args:
        agent_id: The ID of the agent that will perform the action.
        action: The action to perform.
        args: The arguments to pass to the action. For details of each args in
            each action, please refer to
            `https://github.com/camel-ai/oasis/blob/main/oasis/social_agent/agent_action.py`.
    """
    action_type: ActionType
    action_args: Dict[str, Any]

    def init(self, action_type, action_args):
        self.action_type = action_type
        self.action_args = action_args
  • A example of using ManualAction():
from oasis import ActionType

actions = {}

manual_action = ManualAction(
    action=ActionType.CREATE_POST,
    args={"content": "Hello, OASIS world!"}
)

actions[env.agent_graph.get_agents(0)] = manual_action

await env.step(actions)

For more details about the ActionType and corresponding arguments, please refer to the ActionType section.

ActionType

OASIS provides a comprehensive set of actions that simulate real social media behaviors:

Action TypeDescription
SIGNUPRegister a new user with username, name, and bio
CREATE_POSTCreate a new post with text content
LIKE_POSTLike or upvote a post
UNLIKE_POSTRemove a like from a previously liked post
DISLIKE_POSTDislike or downvote a post
UNDO_DISLIKE_POSTRemove a dislike from a previously disliked post
REPOSTRepost content without modification (equivalent to retweet)
QUOTE_POSTRepost with additional commentary
CREATE_COMMENTCreate a comment on a post
LIKE_COMMENTLike a comment
UNLIKE_COMMENTRemove a like from a previously liked comment
DISLIKE_COMMENTDislike a comment
UNDO_DISLIKE_COMMENTRemove a dislike from a previously disliked comment
FOLLOWFollow another user
UNFOLLOWUnfollow a previously followed user
MUTEMute another user (hide their content without unfollowing)
UNMUTEUnmute a previously muted user
SEARCH_POSTSSearch for posts by keywords, post ID, or user ID
SEARCH_USERSearch for users by username, name, bio, or user ID
TRENDGet trending content based on popularity metrics
REFRESHRefresh the timeline to get recommended posts
DO_NOTHINGPerform no action (pass the turn)
PURCHASE_PRODUCTPurchase a product (for e-commerce simulations)
INTERVIEWInterview a user and record the interview result in the database
CREATE_GROUPCreate a new group with a given name
JOIN_GROUPJoin a group by group ID
LEAVE_GROUPLeave a group by group ID
SEND_TO_GROUPSend a message to a group
LISTEN_FROM_GROUPListen for messages from groups

Platform-Specific Actions

OASIS provides platform-specific action sets that can be accessed using class methods:

Reddit Actions

# Get all Reddit-specific actions, return a list of ActionType
available_actions = ActionType.get_default_reddit_actions()

The Reddit action set includes:

  • LIKE_POST
  • DISLIKE_POST
  • CREATE_POST
  • CREATE_COMMENT
  • LIKE_COMMENT
  • DISLIKE_COMMENT
  • SEARCH_POSTS
  • SEARCH_USER
  • TREND
  • REFRESH
  • DO_NOTHING
  • FOLLOW
  • MUTE

Twitter Actions

# Get all Reddit-specific actions, return a list of ActionType
available_actions = ActionType.get_default_twitter_actions()

The Twitter action set includes:

  • CREATE_POST
  • LIKE_POST
  • REPOST
  • FOLLOW
  • DO_NOTHING
  • QUOTE_POST

Arguments for ManualAction

CREATE_POST

action = ManualAction(
    action=ActionType.CREATE_POST,
    args={"content": "Hello, OASIS world!"}
)

LIKE_POST

action = ManualAction(
    action=ActionType.LIKE_POST,
    args={"post_id": 123}
)

UNLIKE_POST

action = ManualAction(
    action=ActionType.UNLIKE_POST,
    args={"post_id": 123}
)

DISLIKE_POST

action = ManualAction(
    action=ActionType.DISLIKE_POST,
    args={"post_id": 123}
)

UNDO_DISLIKE_POST

action = ManualAction(
    action=ActionType.UNDO_DISLIKE_POST,
    args={"post_id": 123}
)

REPOST

action = ManualAction(
    action=ActionType.REPOST,
    args={"post_id": 123}
)

QUOTE_POST

action = ManualAction(
    action=ActionType.QUOTE_POST,
    args={"post_id": 123, "quote_content": "This is amazing content!"}
)

CREATE_COMMENT

action = ManualAction(
    action=ActionType.CREATE_COMMENT,
    args={"post_id": 123, "content": "Great post! I completely agree."}
)

LIKE_COMMENT

action = ManualAction(
    action=ActionType.LIKE_COMMENT,
    args={"comment_id": 456}
)

UNLIKE_COMMENT

action = ManualAction(
    action=ActionType.UNLIKE_COMMENT,
    args={"comment_id": 456}
)

DISLIKE_COMMENT

action = ManualAction(
    action=ActionType.DISLIKE_COMMENT,
    args={"comment_id": 456}
)

UNDO_DISLIKE_COMMENT

action = ManualAction(
    action=ActionType.UNDO_DISLIKE_COMMENT,
    args={"comment_id": 456}
)

FOLLOW

action = ManualAction(
    action=ActionType.FOLLOW,
    args={"followee_id": 789}
)

UNFOLLOW

action = ManualAction(
    action=ActionType.UNFOLLOW,
    args={"followee_id": 789}
)

MUTE

action = ManualAction(
    action=ActionType.MUTE,
    args={"mutee_id": 789}
)

UNMUTE

action = ManualAction(
    action=ActionType.UNMUTE,
    args={"mutee_id": 789}
)

SEARCH_POSTS

action = ManualAction(
    action=ActionType.SEARCH_POSTS,
    args={"query": "artificial intelligence"}
)

SEARCH_USER

action = ManualAction(
    action=ActionType.SEARCH_USER,
    args={"query": "john"}
)

TREND

action = ManualAction(
    action=ActionType.TREND,
    args={}
)

REFRESH

action = ManualAction(
    action=ActionType.REFRESH,
    args={}
)

DO_NOTHING

action = ManualAction(
    action=ActionType.DO_NOTHING,
    args={}
)

PURCHASE_PRODUCT

action = ManualAction(
    action=ActionType.PURCHASE_PRODUCT,
    args={"product_name": "Premium Subscription", "purchase_num": 1}
)

INTERVIEW

action = ManualAction(
    action=ActionType.INTERVIEW,
    args={"prompt": "What is your name?"}
)

CREATE_GROUP

action = ManualAction(
    action=ActionType.CREATE_GROUP,
    args={"group_name": "OASIS Fans"}
)

JOIN_GROUP

action = ManualAction(
    action=ActionType.JOIN_GROUP,
    args={"group_id": 1}
)

LEAVE_GROUP

action = ManualAction(
    action=ActionType.LEAVE_GROUP,
    args={"group_id": 1}
)

SEND_TO_GROUP

action = ManualAction(
    action=ActionType.SEND_TO_GROUP,
    args={"group_id": 1, "message": "Hello, OASIS fans!"}
)

LISTEN_FROM_GROUP

action = ManualAction(
    action=ActionType.LISTEN_FROM_GROUP,
    args={}
)