RouterStream¶
This docs was updated at: 2026-02-23
com.paragon.agents.RouterStream ยท Class
Streaming wrapper for RouterAgent that provides event callbacks during routing and execution.
RouterStream first classifies the input, then executes the selected agent with streaming.
router.routeStream("Help with billing")
.onRouteSelected(agent -> System.out.println("Routed to: " + agent.name()))
.onTextDelta(System.out::print)
.onComplete(result -> System.out.println("\nDone!"))
.start();
Since: 1.0
Methods¶
onRouteSelected¶
Called when a route is selected.
Parameters
| Name | Description |
|---|---|
callback |
receives the selected Interactable |
Returns
this stream
onTextDelta¶
Called for each text delta during streaming.
Parameters
| Name | Description |
|---|---|
callback |
receives text chunks |
Returns
this stream
onComplete¶
Called when streaming completes successfully.
Parameters
| Name | Description |
|---|---|
callback |
receives the final result |
Returns
this stream
onError¶
Called when an error occurs.
Parameters
| Name | Description |
|---|---|
callback |
receives the error |
Returns
this stream
onTurnStart¶
Called at the start of each turn.
Parameters
| Name | Description |
|---|---|
callback |
receives the turn number |
Returns
this stream
onToolExecuted¶
Called when a tool execution completes.
Parameters
| Name | Description |
|---|---|
callback |
receives the tool execution result |
Returns
this stream
onHandoff¶
Called when a handoff occurs within the selected agent.
Parameters
| Name | Description |
|---|---|
callback |
receives the handoff |
Returns
this stream
start¶
Starts the streaming router execution. Blocks until completion.
On virtual threads, blocking is efficient and does not consume platform threads.
Returns
the final result