ParallelStream¶
This docs was updated at: 2026-03-21
com.paragon.agents.ParallelStream ยท Class
Streaming wrapper for ParallelAgents that provides event callbacks during parallel execution.
team.runStream("Analyze market")
.onAgentTextDelta((agent, delta) -> System.out.print("[" + agent.name() + "] " + delta))
.onAgentComplete((agent, result) -> System.out.println(agent.name() + " done!"))
.onComplete(results -> System.out.println("All done!"))
.start();
Since: 1.0
Methods¶
onAgentTextDelta¶
public @NonNull ParallelStream onAgentTextDelta(
@NonNull BiConsumer<Interactable, String> callback)
Called for each text delta from any member.
Parameters
| Name | Description |
|---|---|
callback |
receives the member and text chunk |
Returns
this stream
onAgentComplete¶
public @NonNull ParallelStream onAgentComplete(
@NonNull BiConsumer<Interactable, AgentResult> callback)
Called when an individual member completes.
Parameters
| Name | Description |
|---|---|
callback |
receives the member and its result |
Returns
this stream
onComplete¶
Called when all agents complete (for ALL mode).
Parameters
| Name | Description |
|---|---|
callback |
receives list of all results |
Returns
this stream
onFirstComplete¶
Called when the first agent completes (for FIRST mode).
Parameters
| Name | Description |
|---|---|
callback |
receives the first result |
Returns
this stream
onSynthesisComplete¶
Called when synthesis completes (for SYNTHESIZE mode).
Parameters
| Name | Description |
|---|---|
callback |
receives the synthesized result |
Returns
this stream
onError¶
Called when an error occurs.
Parameters
| Name | Description |
|---|---|
callback |
receives the error |
Returns
this stream
onAgentTurnStart¶
public @NonNull ParallelStream onAgentTurnStart(
@NonNull BiConsumer<Interactable, Integer> callback)
Called at the start of each turn for any member.
Parameters
| Name | Description |
|---|---|
callback |
receives the member and turn number |
Returns
this stream
onAgentToolExecuted¶
public @NonNull ParallelStream onAgentToolExecuted(
@NonNull BiConsumer<Interactable, ToolExecution> callback)
Called when a tool is executed by any member agent.
Parameters
| Name | Description |
|---|---|
callback |
receives the member and the tool execution result |
Returns
this stream
onAgentGuardrailFailed¶
public @NonNull ParallelStream onAgentGuardrailFailed(
@NonNull BiConsumer<Interactable, GuardrailResult.Failed> callback)
Called when a guardrail fails for any member agent.
Parameters
| Name | Description |
|---|---|
callback |
receives the member and the failed guardrail result |
Returns
this stream
onAgentClientSideTool¶
public @NonNull ParallelStream onAgentClientSideTool(
@NonNull BiConsumer<Interactable, FunctionToolCall> callback)
Called when a client-side tool (stopsLoop = true) is detected in any member agent.
Parameters
| Name | Description |
|---|---|
callback |
receives the member and the tool call that triggered the exit |
Returns
this stream
onAgentCancelled¶
Called (FIRST mode only) for each agent whose result was discarded because another completed first.
Parameters
| Name | Description |
|---|---|
callback |
receives the agent that lost the race |
Returns
this stream
onAgentError¶
Called when a member agent's virtual thread throws an exception before producing a result (ALL and SYNTHESIZE modes).
Parameters
| Name | Description |
|---|---|
callback |
receives the member and the error |
Returns
this stream
onSynthesisStart¶
Called (SYNTHESIZE mode only) just before the synthesizer agent starts, with all gathered member results.
Parameters
| Name | Description |
|---|---|
callback |
receives the list of all member results |
Returns
this stream
startBlocking¶
Starts the streaming parallel execution. Blocks until completion.
On virtual threads, blocking is efficient and does not consume platform threads.
Returns
results based on mode: List
start¶
Starts the streaming parallel execution. Blocks until completion.
On virtual threads, blocking is efficient and does not consume platform threads.
Returns
results based on mode: List