NetworkStream¶
This docs was updated at: 2026-02-23
com.paragon.agents.NetworkStream ยท Class
Streaming wrapper for AgentNetwork that provides event callbacks during network discussions.
network.discussStream("Should AI be regulated?")
.onPeerTextDelta((peer, delta) -> System.out.print("[" + peer.name() + "] " + delta))
.onRoundStart(round -> System.out.println("=== Round " + round + " ==="))
.onComplete(result -> System.out.println("Discussion finished!"))
.start();
Since: 1.0
Methods¶
onPeerTextDelta¶
Called for each text delta from any peer.
Parameters
| Name | Description |
|---|---|
callback |
receives the peer and text chunk |
Returns
this stream
onPeerComplete¶
public @NonNull NetworkStream onPeerComplete(
@NonNull BiConsumer<Interactable, AgentResult> callback)
Called when an individual peer completes its contribution.
Parameters
| Name | Description |
|---|---|
callback |
receives the peer and its result |
Returns
this stream
onRoundStart¶
Called when a new discussion round begins.
Parameters
| Name | Description |
|---|---|
callback |
receives the round number (1-indexed) |
Returns
this stream
onRoundComplete¶
public @NonNull NetworkStream onRoundComplete(
@NonNull Consumer<List<AgentNetwork.Contribution>> callback)
Called when a discussion round completes.
Parameters
| Name | Description |
|---|---|
callback |
receives the contributions from that round |
Returns
this stream
onSynthesisTextDelta¶
Called for each text delta from the synthesizer agent (if configured).
Parameters
| Name | Description |
|---|---|
callback |
receives the text chunk |
Returns
this stream
onComplete¶
Called when the network discussion completes.
Parameters
| Name | Description |
|---|---|
callback |
receives the final network result |
Returns
this stream
onError¶
Called when an error occurs.
Parameters
| Name | Description |
|---|---|
callback |
receives the error |
Returns
this stream
start¶
Starts the streaming network execution. Blocks until completion.
On virtual threads, blocking is efficient and does not consume platform threads.
Returns
the network result