agentscope-java icon indicating copy to clipboard operation
agentscope-java copied to clipboard

agentscope-copilotkit历史消息回放数据如何持久化存储

Open shenghuitian opened this issue 3 months ago • 4 comments

  1. agentscope-copilotkit中历史消息回放是基于内存存储的(InMemoryAgentEventStore),如何持久化到数据库当中,是否能与AgentState结合起来使用?
  2. 现在基于AgentEvent的历史消息回放方式,进行历史消息渲染时,前端会接收大量aguiEvent,会影响前端渲染性能,是否有其他方式实现历史消息回放?

shenghuitian avatar Sep 01 '26 07:09 shenghuitian

  1. 可以通过中间件保存AgentEvent,保存前可以把增量事件压缩一下减少数据量, 应该能与AgentState结合使用,将AgentScope Msg 转成AguiMessage,但是有一点要注意AgentState里的Msg list 可能被压缩过。
  2. 可以自己实现一个事件回放接口,做好分页,前端通过agent.setMessages([]),agent.addMessage(m) 等渲染

dragondyt avatar Sep 01 '26 08:09 dragondyt

官方后续是否有计划拓展AgentEvent数据库持久化及回放的能力呢?

shenghuitian avatar Sep 01 '26 08:09 shenghuitian

agentscope-copilotkit 模块目前只是一个用来测试agui协议兼容性的示例,持久化和回放应该是应用层根据自己的技术栈实现的

dragondyt avatar Sep 01 '26 10:09 dragondyt

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 — a ConcurrentHashMap per thread capped at MAX_EVENTS_PER_THREAD = 5_000 (line 41).
  • PersistingAgentEventEnricher.java:38 only appends events into that in-memory store; DemoThreadStore.java:47 is also in-memory (backed by ThreadSessionManager, a ConcurrentHashMap in agentscope-spring-boot-starters/agentscope-agui-spring-boot-starter/.../ThreadSessionManager.java:71).
  • Repo-wide, the AgentEventStore type is referenced only by those 5 copilotkit example files. There is no DB/file implementation of an AgentEvent store to switch to, and the existing agentscope-extensions-{jdbc,mysql,redis,mongodb} stores persist Msg sessions — not AG-UI event streams. So combining replay with AgentState persistence is not possible out of the box today; it would need a new store implementation behind the same AgentEventStore seam.

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

oss-maintainer avatar Sep 14 '26 05:09 oss-maintainer