import type { AssistantMessage, ToolResultMessage } from "../types"; /** Runtime settings for cross-turn tool-call repetition detection. */ export interface ToolCallLoopGuardOptions { readonly threshold: number; readonly exemptTools: readonly string[]; /** Window size for alternating-pattern (A,B,A,B,…) cycle detection; defaults to 6. */ readonly cycleWindowSize?: number; } /** A completed assistant turn plus the tool results it produced. */ export interface ToolCallLoopTurn { readonly message: AssistantMessage; readonly toolResults: readonly ToolResultMessage[]; } /** Details needed to steer the model away from a repeated tool call. */ export interface RepeatedToolCallDetection { readonly kind: "repeated_tool_call"; readonly toolName: string; readonly count: number; readonly resultSummary: string; readonly argumentsSummary: string; } /** Details needed to steer the model away from an alternating tool-call cycle (A,B,A,B,…). */ export interface CyclicalToolCallDetection { readonly kind: "cyclical_tool_calls"; /** Distinct tool names seen in the detection window, in first-seen order. */ readonly toolNames: readonly string[]; readonly windowSize: number; } export type ToolCallLoopDetection = RepeatedToolCallDetection | CyclicalToolCallDetection; /** Detects consecutive identical assistant tool calls across model turns. */ export declare class ToolCallLoopGuard { #private; constructor(options: ToolCallLoopGuardOptions); /** Records one completed turn and returns the threshold/cycle hit, if any. */ recordTurn(turn: ToolCallLoopTurn): ToolCallLoopDetection | null; }