agentscope.session

The session module in agentscope.

class SessionBase[source]

Bases: object

The base class for session in agentscope.

__init__(session_id)[source]

Initialize the session base class

Parameters:

session_id (str)

Return type:

None

session_id: str

The session id

abstract async save_session_state(**state_modules_mapping)[source]

Save the session state

Parameters:

state_modules_mapping (StateModule)

Return type:

None

abstract async load_session_state(*args, **kwargs)[source]

Load the session state

Parameters:
  • args (Any)

  • kwargs (Any)

Return type:

None

class JSONSession[source]

Bases: SessionBase

The JSON session class.

__init__(session_id, save_dir)[source]

Initialize the JSON session class.

Parameters:
  • session_id (str) – The session id.

  • save_dir (str) – The directory to save the session state.

Return type:

None

property save_path: str

The path to save the session state.

async save_session_state(**state_modules_mapping)[source]

Load the state dictionary from a JSON file.

Parameters:

**state_modules_mapping (dict[str, StateModule]) – A dictionary mapping of state module names to their instances.

Return type:

None

async load_session_state(**state_modules_mapping)[source]

Get the state dictionary to be saved to a JSON file.

Parameters:

state_modules_mapping (list[StateModule]) – The list of state modules to be loaded.

Return type:

None