agentscope-copilotkit历史消息回放数据如何持久化存储
- agentscope-copilotkit中历史消息回放是基于内存存储的(InMemoryAgentEventStore),如何持久化到数据库当中,是否能与AgentState结合起来使用?
- 现在基于AgentEvent的历史消息回放方式,进行历史消息渲染时,前端会接收大量aguiEvent,会影响前端渲染性能,是否有其他方式实现历史消息回放?
- 可以通过中间件保存AgentEvent,保存前可以把增量事件压缩一下减少数据量, 应该能与AgentState结合使用,将AgentScope Msg 转成AguiMessage,但是有一点要注意AgentState里的Msg list 可能被压缩过。
- 可以自己实现一个事件回放接口,做好分页,前端通过agent.setMessages([]),agent.addMessage(m) 等渲染
官方后续是否有计划拓展AgentEvent数据库持久化及回放的能力呢?
agentscope-copilotkit 模块目前只是一个用来测试agui协议兼容性的示例,持久化和回放应该是应用层根据自己的技术栈实现的
Issue Evaluation
Category: question
This is a how-to / roadmap question, not a defect. What the code supports today:
1. Persistence of replay data. agentscope-copilotkit is an example app, not a supported integration module, and its event layer is deliberately in-memory only:
agentscope-examples/agentscope-copilotkit/src/main/java/io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:39— aConcurrentHashMapper thread capped atMAX_EVENTS_PER_THREAD = 5_000(line 41).PersistingAgentEventEnricher.java:38only appends events into that in-memory store;DemoThreadStore.java:47is also in-memory (backed byThreadSessionManager, aConcurrentHashMapinagentscope-spring-boot-starters/agentscope-agui-spring-boot-starter/.../ThreadSessionManager.java:71).- Repo-wide, the
AgentEventStoretype is referenced only by those 5 copilotkit example files. There is no DB/file implementation of an AgentEvent store to switch to, and the existingagentscope-extensions-{jdbc,mysql,redis,mongodb}stores persistMsgsessions — not AG-UI event streams. So combining replay withAgentStatepersistence is not possible out of the box today; it would need a new store implementation behind the sameAgentEventStoreseam.
2. Replay volume / front-end rendering. Re-projecting every stored event through AgentEventAguiReplayer on connect is the example's own approach, and it does not scale. The usual fix is to serve history as aggregated messages (one rendered message per assistant turn) and only stream live events for the in-flight turn — i.e. keep the raw event stream for audit/tracing and render from a compacted view, rather than replaying all events to the browser.
If durable event persistence matters for your deployment, the reasonable next step is a scoped enhancement issue (implement a JDBC/Redis-backed AgentEventStore in an extension module + a compacted history endpoint). Flagging for maintainer input on whether that belongs in agentscope-extensions-protocol/agentscope-extensions-agui or should stay example-level.
Automated evaluation by github-manager-bot