SubagentEventBus
public interface SubagentEventBus
io/agentscope/core/agent/SubagentEventBus.java:37–69定义子智能体事件总线契约的接口。位于 io.agentscope.core.agent 包。核心成员包括 emit、fromContext、CONTEXT_KEY。
A lightweight channel that allows synchronously-invoked subagents to push their Events
into the parent agent's Flux<Event> stream.
An instance is created inside AgentBase#createEventStream and stored in the Reactor
Context under #CONTEXT_KEY. When a tool method (e.g. agent_spawn) runs inside
that stream pipeline, it can retrieve the bus via #fromContext(ContextView) and forward
each child event to the parent sink.
Events emitted through the bus must already carry an EventSource (attached
by the caller) so downstream consumers can identify the originating subagent.
When the parent agent is invoked via call() (non-streaming), no bus is present in the
context and #fromContext returns Optional#empty(), allowing callers to fall back
gracefully to the blocking path.
字段摘要Field Summary
| 字段Field | 类型Type | 说明Description |
|---|---|---|
CONTEXT_KEY | String | 上下文键字段。 Reactor Context key under which the bus instance is stored. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void emit(Event event) | 设置发出。 Emits a subagent event into the parent stream. |
static public Optional<SubagentEventBus> fromContext(ContextView ctx)static | 设置来自上下文。 Retrieves the `SubagentEventBus` from the Reactor Context, if present. |
字段详情Field Detail
CONTEXT_KEY
String CONTEXT_KEY
上下文键字段。声明为 String CONTEXT_KEY。
Reactor Context key under which the bus instance is stored.
io/agentscope/core/agent/SubagentEventBus.java:43方法详情Method Detail
emit
public void emit(Event event)
设置发出。
Emits a subagent event into the parent stream.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
event | Event | 事件(类型 `Event`)。the event to forward (must have `EventSource` set) |
io/agentscope/core/agent/SubagentEventBus.java:54fromContext
static public Optional<SubagentEventBus> fromContext(ContextView ctx)
设置来自上下文。
Retrieves the SubagentEventBus from the Reactor Context, if present.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
ctx | ContextView | 运行时上下文(类型 `ContextView`)。the current Reactor subscriber context |
Optional<SubagentEventBus>io/agentscope/core/agent/SubagentEventBus.java:63–68