DocsRuntimellm-providersProviderDependencies
Package: @hexos/runtime

Runtime dependencies injected into LLM provider streaming functions.

Contains all necessary runtime operations that providers delegate to the parent AgentRuntime, including infrastructure retry logic, approval flows, tool execution guards, and context building. This interface decouples provider implementations from runtime internals.

All methods are synchronous or async as needed. Approval flow methods (requiresApproval, waitForApproval) enable human-in-the-loop patterns.

interface ProviderDependencies {
    hooks?: ProviderHooks;
    withInfrastructureRetry<T>(operation: () => Promise<T>): Promise<T>;
    buildToolContext(input: RuntimeInput, agentId: string): ToolContext;
    requiresApproval(toolDef: ToolDefinition, toolContext: ToolContext): boolean;
    waitForApproval(
    conversationId: string,
    toolCallId: string,
    toolName: string,
    toolDef: ToolDefinition,
    args: unknown,
    agentId: string
  ): Promise<ProviderApprovalDecision>;
    executeToolWithGuards(
    toolDef: ToolDefinition,
    toolInput: unknown,
    toolContext: ToolContext
  ): Promise<unknown>;
    getErrorInfo(error: unknown, fallbackCode?: string): ProviderErrorInfo;
}

hooks

withInfrastructureRetry

(operation: () => Promise) => Promise

buildToolContext

(input: RuntimeInput, agentId: string) => ToolContext

requiresApproval

(toolDef: ToolDefinition, toolContext: ToolContext) => boolean

waitForApproval

(conversationId: string, toolCallId: string, toolName: string, toolDef: ToolDefinition, args: unknown, agentId: string) => Promise<ProviderApprovalDecision>

executeToolWithGuards

(toolDef: ToolDefinition, toolInput: unknown, toolContext: ToolContext) => Promise

getErrorInfo

(error: unknown, fallbackCode?: string) => ProviderErrorInfo