Skip to content

ParallelStream

This docs was updated at: 2026-02-23

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

public @NonNull ParallelStream onComplete(@NonNull Consumer<List<AgentResult>> callback)

Called when all agents complete (for ALL mode).

Parameters

Name Description
callback receives list of all results

Returns

this stream


onFirstComplete

public @NonNull ParallelStream onFirstComplete(@NonNull Consumer<AgentResult> callback)

Called when the first agent completes (for FIRST mode).

Parameters

Name Description
callback receives the first result

Returns

this stream


onSynthesisComplete

public @NonNull ParallelStream onSynthesisComplete(@NonNull Consumer<AgentResult> callback)

Called when synthesis completes (for SYNTHESIZE mode).

Parameters

Name Description
callback receives the synthesized result

Returns

this stream


onError

public @NonNull ParallelStream onError(@NonNull Consumer<Throwable> callback)

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


start

public @NonNull Object 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 for ALL, AgentResult for FIRST/SYNTHESIZE