Class ContinuationEventStream
- All Implemented Interfaces:
AutoCloseable,Iterable<InteractionSSEStreamEvent>
EventStream of a streaming interactions.create() call that automatically
continues across hops (HTTP requests).
Every event of every hop is yielded verbatim and in order, including each hop's own
interaction.created and intermediate interaction.completed (with status
requires_continuation) events. When a hop completes with requires_continuation and a
token, the next hop is requested from that token. When the transport drops (or the stream ends)
mid-hop after an interaction.status_update checkpoint token, and nothing was yielded
since that checkpoint, the hop is resumed from it; a hop that drops before making progress is
retried from its start token up to InteractionContinuation.MAX_STREAM_RECONNECTS_WITHOUT_PROGRESS
times in a row. SSE error events are terminal; HTTP status errors are not retried here.
Hand-written (not generated). Per-hop state lives in a ContinuationEventStream.Hop record replaced wholesale
when a hop starts, so per-hop fields cannot leak across hops; loop state (next resume token and
owner, no-progress reconnect counter, pending transport error) persists on the stream.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceOpens the stream of a continuation hop. -
Constructor Summary
ConstructorsConstructorDescriptionContinuationEventStream(EventStream<InteractionSSEStreamEvent> initial, ContinuationEventStream.HopOpener opener, String initialContinuationToken, com.google.genai.gaos.InteractionContinuation.CallDeadline deadline) Creates a stream that continuesinitialacross hops. -
Method Summary
Methods inherited from class com.google.genai.gaos.utils.EventStream
iterator, stream, toListMethods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ContinuationEventStream
public ContinuationEventStream(EventStream<InteractionSSEStreamEvent> initial, ContinuationEventStream.HopOpener opener, @Nullable String initialContinuationToken, com.google.genai.gaos.InteractionContinuation.CallDeadline deadline) Creates a stream that continuesinitialacross hops.- Parameters:
initial- the first hop's stream (its HTTP response headers were already received)opener- opens the stream of each further hopinitialContinuationToken- the caller's owncontinuation_token, if anydeadline- the whole-call deadline, checked before each hop and before each event
-
-
Method Details
-
next
Description copied from class:EventStreamReturns the next message. If another message does not exist returnsOptional.empty().- Overrides:
nextin classEventStream<InteractionSSEStreamEvent>- Returns:
- the next message or
Optional.empty()if no more messages - Throws:
IOException- when parsing the next message.
-
close
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classEventStream<InteractionSSEStreamEvent>- Throws:
IOException
-
isClosed
public boolean isClosed()- Overrides:
isClosedin classEventStream<InteractionSSEStreamEvent>
-