ProtecteddoneProtected ReadonlyloggerProtected ReadonlymessageProtectedmessagesProtected ReadonlyoptionsProtected ReadonlyrequestProtected ReadonlystreamProtected ReadonlystreamingProtectedterminalProtected ReadonlytoProtected ReadonlytoolProtectedcancelAborts the active provider stream and immediately terminates the iterator, so a next() call pending on
tool execution (which is only cooperatively cancelled via the token forwarded to handlers) settles promptly
instead of stalling until an uninterruptible handler eventually finishes.
ProtectedcollectDispose this object.
ProtectedexecuteProtectedformatProtectedhandleDelivers a part to the consumer. Parts arriving after the iterator is done (e.g. from a tool handler that finishes after cancellation or after the consumer abandoned the iteration) are dropped.
ProtectedinitNOTE: 'next' is defined using a tuple to ensure we report the correct assignability errors in all places.
ProtectedprocessStreams a single completion, emitting text/tool-call parts and collecting the turn's tool calls.
Terminates the iteration when the consumer abandons it, be it by breaking out of a for await loop or
by that loop exiting with an error. Without this, the producer would keep requesting completions,
executing tool calls and buffering parts that nobody will ever read.
Protectedstart
Drives a multi-turn OpenAI Chat Completions conversation with tool calling, executing the tool calls of each turn concurrently via ToolCallExecutor.
This replaces the OpenAI SDK's
chat.completions.runTools(...)runner, whose built-in tool loop executes tool calls strictly sequentially. By driving the raw chunk stream (chat.completions.create({ stream: true })) ourselves, multiple tool calls emitted in a single model turn (e.g. parallel agent delegations) run in parallel.