This page has been superseded by Distributed Storage — MySQL. Content below is kept for reference.
MySQL State Store
agentscope-extensions-mysql persists AgentScope agent state into MySQL. A good fit when you already have a MySQL infrastructure or need transactional / SQL-based access to state data.
Add the dependency
mysql:mysql-connector-j).
Quickstart
Custom database / table names
[a-zA-Z_][a-zA-Z0-9_-]* and be ≤ 64 chars to avoid SQL injection.
Schema
WhencreateIfNotExist=true, the table is created automatically:
- The
(userId, sessionId)pair is packed into thesession_idcolumn as{userSegment}:{sessionId}(userSegment=userId, or__anon__for anonymous sessions). - Single value:
item_index = 0 - List:
item_index = 0, 1, 2, ...— one row per item; an extra row withstate_key='xxx:_hash'is used for change detection.
Direct API usage
MysqlAgentStateStore implements the AgentStateStore interface:
Configuration
truncateAllSessions()issuesTRUNCATE TABLEand requires DROP privilege; DDL is non-rollbackable, so reserve it for tests or ops cleanup.