Public declaration syntax from forge-ts/packages/forge-agent/src/tool-loop.ts Original source SHA-256: 8cc5f367a14480d640e77a45ffc1aa3e657531eb1018a5b0557d27833e1ca5ed Function bodies and constant values are omitted. This is not the complete implementation. Source line 55 export interface ToolLoopConfig { /** The language model to use for inference. */ readonly model: LanguageModel; /** The tool registry containing available tools and their executors. */ readonly registry: ToolRegistry; /** Optional system prompt prepended to every conversation. */ readonly systemPrompt?: string; /** Maximum number of tool loop iterations. Defaults to 10. */ readonly maxIterations?: number; /** Generation options for model calls. */ readonly generateOptions?: GenerateOptions; /** The approval handler for tool execution. Defaults to AutoApprove. */ readonly approvalHandler?: ApprovalHandler; /** Custom stop conditions evaluated after each iteration. */ readonly stopConditions?: readonly AgentStopCondition[]; /** The health profile to update with tool invocations and inference calls. */ readonly healthProfile?: HealthProfile; } Source line 79 export interface ToolLoopIteration { /** The iteration index (0-based). */ readonly index: number; /** The model's response message for this iteration. */ readonly assistantMessage: ModelMessage; /** The tool calls requested by the model (empty if none). */ readonly toolCalls: readonly ToolCall[]; /** The tool results from executing the tool calls (empty if no calls). */ readonly toolResults: readonly ToolResult[]; /** Token usage for this iteration. */ readonly usage: Usage; } Source line 104 export interface ToolLoopOutput { /** The final text response from the model. */ readonly finalText: string; /** All iterations executed during the loop. */ readonly iterations: readonly ToolLoopIteration[]; /** The total token usage across all iterations. */ readonly totalUsage: Usage; /** The reason the loop stopped. */ readonly stopReason: string; /** The complete conversation history including all messages. */ readonly messages: readonly ModelMessage[]; } Source line 148 export async function runToolLoop( config: ToolLoopConfig, userMessage: string ): Promise;