AS AgentScopeAPI 手册 / API Reference

AgentProtocolEventBus

public interface AgentProtocolEventBus
源码Source 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.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
eventRemoteAgentEvent事件(类型 `RemoteAgentEvent`)。The event.
返回Returns RemoteAgentEvent
返回RemoteAgentEvent。Returns remote agent event.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:33

subscribe

public Flux<RemoteAgentEvent> subscribe(String taskId, long fromSeq)

执行订阅相关操作。

Subscribes to a task's event stream, replaying only events whose sequence is greater than fromSeq.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
fromSeqlong来自 Seq(类型 `long`)。The from seq.
返回Returns Flux<RemoteAgentEvent>
返回Flux。Returns flux.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:39

complete

public void complete(String taskId)

设置该参数。

Completes and releases the event stream for a terminal task.

参数Parameters
名称Name类型Type说明Description
taskIdString任务标识(类型 `String`)。The task id.
源码Source io/agentscope/extensions/agentprotocol/AgentProtocolEventBus.java:42
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.