Open a stream
Stream stream = client.sendSubscribe(taskId, message);
stream.forEach(delta -> {
switch (delta.type()) {
case TEXT -> renderText(delta.text());
case TOOL_RESULT -> handleToolResult(delta.result());
case COMPLETE -> markDone();
}
}); Advertisement
Backpressure
The underlying HTTP client pauses reads if you don't consume fast enough. Natural backpressure.
Advertisement
Reconnect
If the stream drops mid-task, resume with the same task_id + a last-event-id. Server continues from where you left off.