StreamToolExecutor class

Executes tools from LLM chunks and manages the tool execution loop.

This class handles:

  • Collecting tool calls from a stream of chunks
  • Executing tools using the LLMTool interface
  • Building tool response messages
  • Managing tool attempt limits
  • Recursively continuing conversations when tools are executed

Constructors

StreamToolExecutor({required List<LLMTool> tools, required dynamic extra, required int maxToolAttempts, required Stream<LLMChunk> streamChatCallback(String model, List<LLMMessage> messages, List<LLMTool> tools, dynamic extra, int toolAttempts)})
Creates a stream tool executor.

Properties

extra → dynamic
Extra context to pass to tool executions.
final
hashCode int
The hash code for this object.
no setterinherited
maxToolAttempts int
Maximum number of tool execution attempts.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
streamChatCallback Stream<LLMChunk> Function(String model, List<LLMMessage> messages, List<LLMTool> tools, dynamic extra, int toolAttempts)
Callback function to recursively call streamChat when tools need execution.
final
tools List<LLMTool>
The tools available for execution.
final

Methods

executeTools({required Stream<LLMChunk> chunkStream, required String model, required List<LLMMessage> initialMessages, required int toolAttempts}) Stream<LLMChunk>
Processes a stream of chunks and executes tools when needed.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited