Class AgentOSOrchestrator

Description

The AgentOSOrchestrator is responsible for unifying the request handling pipeline for AgentOS. It bridges the high-level AgentOSInput from the public API to the internal GMI processing 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.

Constructors

Methods

  • Async

    Initializes the AgentOSOrchestrator with its configuration and dependencies. This method must be called successfully before orchestrating any turns.

    Parameters

    Returns Promise<void>

    A Promise that resolves when initialization is complete.

    Throws

    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.

    Parameters

    • streamId: string

    Returns null | {
        userId: string;
        sessionId: string;
        personaId: string;
        conversationId: string;
    }

  • 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.

    Parameters

    Returns Promise<string>

    The ID of the stream to which responses will be pushed.

    Throws

    If critical initialization or setup fails.

  • 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.

    Parameters

    • agentOSStreamId: string

      The stream the guardrail blocked.

    • toolCallIds: undefined | readonly string[]

      The ids of the calls the block withheld, or undefined for a block that withheld none.

    • refusal: GMIToolCallRefusal

      What the refused tool results say.

    Returns Promise<boolean>

    Whether a pause was dropped.

    Throws

    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.

    Parameters

    • agentOSStreamId: string

    Returns boolean

  • Handles the result of an external tool execution, feeding it back into the relevant GMI instance for continued processing. Delegates to ExternalToolResultHandler.

    Parameters

    • agentOSStreamId: string
    • toolCallId: string
    • toolName: string
    • toolOutput: any
    • isSuccess: boolean
    • Optional errorMessage: string

    Returns Promise<void>

  • Async

    Shuts down the AgentOSOrchestrator. Currently, this mainly involves clearing active stream contexts. Dependencies like GMIManager are assumed to be shut down by AgentOS.

    Returns Promise<void>

    A promise that resolves when shutdown is complete.