AgentStream

org.llm4s.javaapi.AgentStream
final class AgentStream

A streaming agent turn from JAgent.stream, JAgent.streamResume or JAgent.streamRecover, whose events are being delivered to its AgentStreamListener: cancel it, or await its result.

AgentStream stream = agent.stream(threadId, "Explain monads", listener).get();
LlmResult<JAgentResult> result = stream.await();   // or stream.cancel()

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Blocks until the listener has returned from its last call - AgentStreamListener.onComplete or AgentStreamListener.onError - then returns the same outcome. A call whose thread is interrupted first returns a failed result (CancelledError), with the interrupt flag still set, and the turn carries on: only cancel stops it. A call from the listener itself, which would wait on itself, returns a failed result at once.

Blocks until the listener has returned from its last call - AgentStreamListener.onComplete or AgentStreamListener.onError - then returns the same outcome. A call whose thread is interrupted first returns a failed result (CancelledError), with the interrupt flag still set, and the turn carries on: only cancel stops it. A call from the listener itself, which would wait on itself, returns a failed result at once.

Attributes

def cancel(): Unit

Cancels the turn and returns once it has ended; the thread is left for JAgent.streamRecover. The listener receives at most the event already being delivered, then AgentStreamListener.onError with the cancellation - or onComplete, for a turn that had already ended. Safe to call more than once, from any thread, the listener's included. An interrupt does not cut the wait short: it is kept, and the thread's flag is set again on return.

Cancels the turn and returns once it has ended; the thread is left for JAgent.streamRecover. The listener receives at most the event already being delivered, then AgentStreamListener.onError with the cancellation - or onComplete, for a turn that had already ended. Safe to call more than once, from any thread, the listener's included. An interrupt does not cut the wait short: it is kept, and the thread's flag is set again on return.

Attributes