InMemoryAgentEventStore
@Component public final class InMemoryAgentEventStore
io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:38–200In 记忆智能体事件存储,负责持久化与读取数据。位于 io.agentscope.examples.copilotkit.service 包。核心成员包括 append、putRunInputMessages、getRunInputMessages、snapshot、hasEvents、clear。
In-memory AgentEvent log keyed by threadId.
AgentScope AgentEvents are the source of truth. AG-UI frames are projected on demand
(see AgentEventAguiReplayer) for /agent/{agentId}/connect and inspect APIs.
Per-run input messages (user / tool / resume) are stored separately so connect replay can
re-attach them to RUN_STARTED.input, matching CopilotKit's persistence model.
嵌套类摘要Nested Class Summary
| 类Class | 类型Kind | 说明Description |
|---|---|---|
StoredAgentEvent | 记录record | 承载已存储智能体事件数据的记录类型。 One AgentEvent captured during a specific AG-UI run. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void append(String threadId, String runId, AgentEvent event) | 执行追加相关操作。 Append one AgentEvent for a thread/run. |
public void putRunInputMessages(String threadId, String runId, List<AguiMessage> messages) | 执行 `putRunInputMessages` 方法。 Persist the new AG-UI input messages for a run (typically the latest user message). |
public List<AguiMessage> getRunInputMessages(String threadId, String runId) | 获取运行输入消息。 Input messages previously stored for a run, or empty when none. |
public List<StoredAgentEvent> snapshot(String threadId) | 设置快照。 Snapshot of persisted AgentEvents for a thread. |
public boolean hasEvents(String threadId) | 判断是否具有事件。 Whether the thread has any persisted AgentEvents. |
public void clear(String threadId) | 清空或重置内部状态。 Clear events and run inputs for a thread. |
方法详情Method Detail
append
public void append(String threadId, String runId, AgentEvent event)
执行追加相关操作。
Append one AgentEvent for a thread/run.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。thread identifier |
runId | String | 运行标识(类型 `String`)。run identifier that produced the event |
event | AgentEvent | 事件(类型 `AgentEvent`)。source AgentEvent |
io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:57–75putRunInputMessages
public void putRunInputMessages(String threadId, String runId, List<AguiMessage> messages)
执行 putRunInputMessages 方法。
Persist the new AG-UI input messages for a run (typically the latest user message).
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。thread identifier |
runId | String | 运行标识(类型 `String`)。run identifier |
messages | List<AguiMessage> | 消息列表(类型 `List`)。candidate input messages from `RunAgentInput` |
io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:87–114getRunInputMessages
public List<AguiMessage> getRunInputMessages(String threadId, String runId)
获取运行输入消息。
Input messages previously stored for a run, or empty when none.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。thread identifier |
runId | String | 运行标识(类型 `String`)。run identifier |
List<AguiMessage>io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:123–133snapshot
public List<StoredAgentEvent> snapshot(String threadId)
设置快照。
Snapshot of persisted AgentEvents for a thread.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。thread identifier |
List<StoredAgentEvent>io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:141–149hasEvents
public boolean hasEvents(String threadId)
判断是否具有事件。
Whether the thread has any persisted AgentEvents.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。thread identifier |
booleanio/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:157–165clear
public void clear(String threadId)
清空或重置内部状态。
Clear events and run inputs for a thread.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
threadId | String | 会话线程标识(类型 `String`)。thread identifier |
io/agentscope/examples/copilotkit/service/InMemoryAgentEventStore.java:172–175嵌套类详情Nested Class Detail
StoredAgentEvent
public record StoredAgentEvent(String runId, AgentEvent event)承载已存储智能体事件数据的记录类型。位于 io.agentscope.examples.copilotkit.service 包。核心成员包括 runId、event。
One AgentEvent captured during a specific AG-UI run.