import io.agentscope.core.session.Session;
import io.agentscope.core.state.SessionKey;
import io.agentscope.core.state.SimpleSessionKey;
import io.agentscope.core.state.State;
// 定义状态类
public record UserPreferences(String theme, String language) implements State {}
// 保存单个状态
session.save(sessionKey, "preferences", new UserPreferences("dark", "zh"));
// 获取单个状态
Optional<UserPreferences> prefs = session.get(sessionKey, "preferences", UserPreferences.class);
// 保存状态列表
session.save(sessionKey, "history", List.of(msg1State, msg2State));
// 获取状态列表
List<MsgState> history = session.getList(sessionKey, "history", MsgState.class);