Skip to main content
Prerequisite: Streaming basicsstream() API, EventType, StreamOptions, SSE integration. This page focuses on HarnessAgent’s child-agent event forwarding mechanism.
When a parent HarnessAgent.stream() triggers agent_spawn or agent_send, all intermediate events from the child agent are injected into the parent Flux<Event> in real time, tagged with an EventSource that identifies their origin — no extra configuration needed.

How It Works

Key constraint: the bus only exists in stream() mode. When using call(), no bus is present and agent_spawn falls back to the blocking invokeAgent path with no behaviour change.

Event Timeline

Parent events have source == null; child events have source != null.

Identifying the Source with EventSource

EventSource Field Reference

Path convention: <parentSessionId>/<agentId>. For deeper nesting it extends naturally: sess-001/planner/executor.

Multi-level Nesting (Grandchild Agents)

A child HarnessAgent injects its own bus at its stream() entry point. Grandchild events are first captured by the child bus (depth+1), then flow out through the child Flux<Event>, where AgentSpawnTool in the grandparent forwards them again to the grandparent bus. The path field accumulates depth automatically.
Filter by depth or path prefix to target any level:

Common Consumption Patterns

1. Real-time UI Rendering per Agent

Route events to separate UI panels based on source:

2. Await Child Agent’s Final Reply

If you only care about the child’s result text (not intermediate events):

3. Collect and Group by Agent

4. SSE with Source Metadata

Forward child-agent origin to the browser:

Error Handling

When a child agent throws internally, the framework catches the exception and writes it as a TOOL_RESULT error string. The onError signal is not propagated to the parent Flux, so the parent stream continues normally. For fatal errors in the parent stream itself, standard Reactor semantics apply:

Scope Boundaries


  • Streaming Basicsstream() API, EventType, full StreamOptions reference
  • Subagent — Subagent declarations, agent_spawn / agent_send parameters
  • ArchitectureSubagentEventBus, Reactor Context injection, and StreamingHook lifecycle