接口 SubagentEventBus
Events
into the parent agent's Flux<Event> stream.
An instance is created inside AgentBase.createEventStream(io.agentscope.core.agent.StreamOptions, java.util.function.Supplier<reactor.core.publisher.Mono<io.agentscope.core.message.Msg>>) 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(reactor.util.context.ContextView) returns Optional.empty(), allowing callers to fall back
gracefully to the blocking path.
-
字段概要
字段 -
方法概要
修饰符和类型方法说明voidEmits a subagent event into the parent stream.static Optional<SubagentEventBus> fromContext(reactor.util.context.ContextView ctx) Retrieves theSubagentEventBusfrom the Reactor Context, if present.
-
字段详细资料
-
CONTEXT_KEY
Reactor Context key under which the bus instance is stored. Internal use only; usefromContext(ContextView)for retrieval.- 另请参阅:
-
-
方法详细资料
-
emit
Emits a subagent event into the parent stream. The event should carry a non-nullEventSourceidentifying the originating subagent.This method is safe to call from any thread; the underlying
FluxSink.nextis thread-safe.- 参数:
event- the event to forward (must haveEventSourceset)
-
fromContext
Retrieves theSubagentEventBusfrom the Reactor Context, if present.- 参数:
ctx- the current Reactor subscriber context- 返回:
- an
Optionalcontaining the bus, or empty when running outside a streaming pipeline
-