Async Initializes the AgentOSOrchestrator with its configuration and dependencies. This method must be called successfully before orchestrating any turns.
Configuration settings for the orchestrator.
Required services.
A Promise that resolves when initialization is complete.
If any critical dependency is missing or config is invalid.
Who a live stream belongs to, for the guardrails that judge its continuation; null once the stream has ended.
Async Orchestrates a full logical turn for a user request. This involves managing GMI interaction, tool calls, and streaming responses. Instead of directly yielding, it uses the StreamingManager to push chunks.
The comprehensive input for the current turn.
The ID of the stream to which responses will be pushed.
If critical initialization or setup fails.
Resumes a pause from its snapshot on a new stream. The pause is taken before the stream is made or the session's GMI acquired, so a resume of a pause the conversation no longer holds, whose stream an output guardrail blocked, or that another resume holds, or with a result for a call the pause does not hold, is refused with nothing changed.
The new stream's id.
INVALID_STATE when the pause is not taken.
Drops the pause a stream saved after an output guardrail blocked the stream. With toolCallIds, the calls the
block withheld from the caller (the verdict's toolCallIds), it drops the pause that holds one of them; without,
for a block that withheld no call (a streamed delta, or the chunk of calls the runtime runs itself, after which the
turn goes on inside the runtime), it drops the pause the stream saves whatever calls it holds. It waits for the
stream's turn or resumed turn to end, since a turn can save its pause after it streams the call or after the
block; then, when the conversation's pending request is this stream's, it records a refused tool result for each
call of the pause, clears the pending request and closes the stream, so the call can be neither continued on the
stream nor resumed from the conversation. Anything else is left as it is. From the call until the drop ends, the
stream is held as blocked (see isStreamBlocked): a pause the turn saves meanwhile is not offered, resumed
or continued. The stream is closed even when the store refuses the conversation's save; the stored conversation
then keeps the pause until the conversation is saved again.
The stream the guardrail blocked.
The ids of the calls the block withheld, or undefined for a block that withheld none.
What the refused tool results say.
Whether a pause was dropped.
The store's error when it refuses the save, after the pause is dropped in memory and the stream closed.
Whether an output guardrail blocked the stream and the pause it saves is being dropped: until the drop ends, that
pause is not offered by getPendingExternalToolRequest(), a resume of it is refused, and tool results do not
continue the stream. Before initialize() no stream has run, so none is blocked.
Handles the result of an external tool execution, feeding it back into the relevant GMI instance for continued processing. Delegates to ExternalToolResultHandler.
Optional errorMessage: stringHandles one or more external tool results in batch. Delegates to ExternalToolResultHandler.
Description
The
AgentOSOrchestratoris responsible for unifying the request handling pipeline for AgentOS. It bridges the high-levelAgentOSInputfrom the public API to the internalGMIprocessing logic. It ensures that user requests are routed to the correct GMI, manages the GMI's turn lifecycle, and handles the complex dance of tool calls and streaming responses.