Repository navigation
Replies: 1 comment 2 replies
|
Short answer: EVENT_LOG can work for a multi-tenant platform, and the 2.1 session features ( I read the code at the 1. What's in the table The store table is Commit rows are append-only (JournalSessionLog#L192-L272), the recorder flushes about once a second during a run, and each streamed model chunk is its own event. So you're right about growth: a user in #3816 measured 14.35 MB and 15,252 events after 12 turns. 2. Taking over the storage
What I'd do is give the journal its own table, with tenant and user in the namespace: AbstractJdbcDialect logDialect = AbstractJdbcDialect.from(logDataSource)
.storeTableName("agentscope_session_log")
.build();
BaseStore logStore = JdbcStore.builder(logDataSource).dialect(logDialect).build();
NamespaceFactory tenantUser = rc -> List.of(
"t", Objects.requireNonNull(rc.get("tenantId", String.class), "tenantId"), // your app sets this
"u", rc.getUserId() == null ? "_anon" : rc.getUserId());
HarnessAgent agent = HarnessAgent.builder()
.name("assistant").agentId("assistant").model(model)
.distributedStore(JdbcDistributedStore.create(dataSource)) // files stay in agentscope_store
.filesystem(new RemoteFilesystemSpec().isolationScope(IsolationScope.USER))
.sessionLogStore(new WorkspaceSessionLogStore(new RemoteFilesystem(logStore, tenantUser)))
.build();The user goes in the namespace too because 3. Retention There is none: no TTL, no compaction, no delete method on String ns = String.join("\u001F", "t", tenantId, "u", userId, "__agentscope_session_log_v1__") + "\u001F";
String prefix = new SessionKey(userId, agentId, sessionId).storagePath() + "/";
String pattern = prefix.replace("!", "!!").replace("%", "!%").replace("_", "!_") + "%";DELETE FROM agentscope_session_log
WHERE namespace_path = ? AND item_key LIKE ? ESCAPE '!';The escape matters, because the 4. LEGACY
So: with background tasks, HITL, or a UI that reconnects, keep EVENT_LOG with the setup above plus a cleanup job. For plain request/response chat where you only need the latest state, LEGACY is simpler, but you still need cleanup. One trap to know early: |
Uh oh!
There was an error while loading. Please reload this page.
你好,我需要做一个多用户使用的平台级的 agent,打算使用最新的预发布版本,HarnessAgent 默认使用 eventLog模式,并且使用关系型数据库作为事件存储,我发现全部事件都会存在 agentscope-store的一个 kv 表中。
因為必然会增长很快,其次我没有发现框架有提供扩展支持业务接管单 kv 表这个设定。我想问这个模式真的推荐多用户或者多租户平台级 agent 的场景吗?
或者对于我的场景官方会比较推荐推荐使用 LEGACY 模式?
All reactions