类 StreamOptions

java.lang.Object
io.agentscope.core.agent.StreamOptions

public class StreamOptions extends Object
Configuration options for the StreamableAgent.stream(io.agentscope.core.agent.StreamOptions) API.

Controls which event types to receive and how streaming content is delivered.

Reasoning filtering (Issue #265): Some streaming backends emit both:

  • Reasoning chunks: incremental deltas during the reasoning process
  • Reasoning result: the final consolidated reasoning output

Use isIncludeReasoningChunk() and isIncludeReasoningResult() to filter these reasoning-related emissions when EventType.REASONING is enabled.

Example usage:


 // Only reasoning events, incremental mode
 StreamOptions options = StreamOptions.builder()
     .eventTypes(EventType.REASONING)
     .incremental(true)
     .build();

 // Reasoning events, but hide intermediate deltas and only keep the final reasoning result
 StreamOptions options = StreamOptions.builder()
     .eventTypes(EventType.REASONING)
     .includeReasoningChunk(false)
     .includeReasoningResult(true)
     .incremental(true)
     .build();

 // Multiple specific types
 StreamOptions options = StreamOptions.builder()
     .eventTypes(EventType.REASONING, EventType.TOOL_RESULT)
     .incremental(true)
     .build();
 
  • 方法详细资料

    • defaults

      public static StreamOptions defaults()
      Default options: All event types, incremental mode, include both reasoning chunk and reasoning result.
      返回:
      StreamOptions with default configuration
    • builder

      public static StreamOptions.Builder builder()
      Creates a new builder for StreamOptions.
      返回:
      A new builder instance
    • getEventTypes

      public Set<EventType> getEventTypes()
      Get the set of event types that should be streamed.

      If the set contains EventType.ALL, all event types will be streamed.

      返回:
      The set of event types to stream
    • isIncremental

      public boolean isIncremental()
      Check if incremental mode is enabled.

      In incremental mode, only new content is delivered in each emission. In cumulative mode, all accumulated content is delivered.

      返回:
      true if incremental mode is enabled
    • isIncludeReasoningChunk

      public boolean isIncludeReasoningChunk()
      Whether reasoning "chunk" emissions should be included.

      Reasoning chunks are the incremental delta of the reasoning process during streaming.

      返回:
      true if reasoning chunks should be included
    • isIncludeReasoningResult

      public boolean isIncludeReasoningResult()
      Whether the final reasoning result should be included.

      The reasoning result is the final consolidated reasoning output in the response.

      返回:
      true if the final reasoning result should be included
    • isIncludeActingChunk

      public boolean isIncludeActingChunk()
      Whether acting (tool execution) chunk emissions should be included.

      Acting chunks are the incremental outputs from tool execution via ToolEmitter.

      返回:
      true if acting chunks should be included
    • isIncludeSummaryChunk

      public boolean isIncludeSummaryChunk()
      Whether summary chunk emissions should be included.

      Summary chunks are the incremental outputs from summary generation when max iterations is reached.

      返回:
      true if summary chunks should be included
    • isIncludeSummaryResult

      public boolean isIncludeSummaryResult()
      Whether the final summary result should be included.

      The summary result is the final consolidated summary output when max iterations is reached.

      返回:
      true if the final summary result should be included
    • shouldStream

      public boolean shouldStream(EventType type)
      Check if a specific event type should be streamed.
      参数:
      type - The event type to check
      返回:
      true if this type should be streamed
    • shouldIncludeReasoningEmission

      public boolean shouldIncludeReasoningEmission(boolean isChunk)
      Convenience method for stream implementations to decide whether to emit a reasoning subtype.

      TODO (Issue #265): Thread these flags through the stream event mapping layer where reasoning events are converted into Flux emissions (e.g., when distinguishing chunk vs result).

      参数:
      isChunk - true if the reasoning emission is an incremental chunk, false if it is the final result
      返回:
      true if this reasoning emission should be included
    • shouldIncludeSummaryEmission

      public boolean shouldIncludeSummaryEmission(boolean isChunk)
      Convenience method for stream implementations to decide whether to emit a summary subtype.
      参数:
      isChunk - true if the summary emission is an incremental chunk, false if it is the final result
      返回:
      true if this summary emission should be included