AgentProtocolEventBus
public interface AgentProtocolEventBus
io/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:30–43定义智能体协议事件总线契约的接口。位于 io.agentscope.extensions.agentprotocol 包。核心成员包括 publish、subscribe、complete。
Event bus abstraction used by Agent Protocol task SSE endpoints.
Implementations are responsible for assigning a monotonically increasing sequence per task,
publishing events, and replaying events after fromSeq. The default implementation is
AgentProtocolTaskEventBus, which keeps the replay buffer in process memory. Applications
that need cross-instance streaming can provide a shared implementation, such as a Redis Streams
adapter, as the AgentProtocolEventBus bean.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public RemoteAgentEvent publish(String taskId, RemoteAgentEvent event) | 执行发布相关操作。 Publishes an event for a task and returns the event after protocol fields are assigned. |
public Flux<RemoteAgentEvent> subscribe(String taskId, long fromSeq) | 执行订阅相关操作。 Subscribes to a task's event stream, replaying only events whose sequence is greater than
`fromSeq`. |
public void complete(String taskId) | 设置该参数。 Completes and releases the event stream for a terminal task. |
方法详情Method Detail
publish
public RemoteAgentEvent publish(String taskId, RemoteAgentEvent event)
执行发布相关操作。
Publishes an event for a task and returns the event after protocol fields are assigned.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
event | RemoteAgentEvent | 事件(类型 `RemoteAgentEvent`)。The event. |
RemoteAgentEventio/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:33subscribe
public Flux<RemoteAgentEvent> subscribe(String taskId, long fromSeq)
执行订阅相关操作。
Subscribes to a task's event stream, replaying only events whose sequence is greater than fromSeq.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
fromSeq | long | 来自 Seq(类型 `long`)。The from seq. |
Flux<RemoteAgentEvent>io/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:39complete
public void complete(String taskId)
设置该参数。
Completes and releases the event stream for a terminal task.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
taskId | String | 任务标识(类型 `String`)。The task id. |
io/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:42