/** * Stop Continuation Handler for Single-Agent AgentLoop * * Opt-in handler that detects incomplete responses from the agent, * decides whether to auto-continue, and prevents infinite loops. * * Unlike TaskContinuationEnforcer (multi-agent swarm), this is designed * for the single-agent AgentLoop with manual stop support and * channel-level state tracking. * * Disabled by default — must be explicitly enabled via config. */ /** * Configuration for the StopContinuationHandler. * Disabled by default to preserve backward compatibility. */ export interface StopContinuationConfig { /** Whether continuation detection is enabled. @default false */ enabled: boolean; /** Maximum number of auto-continuation retries per channel. @default 3 */ maxRetries: number; /** Markers that indicate the response is complete (checked in last 3 lines). */ completionMarkers: string[]; } /** * Result of analyzing a response for continuation need. */ export interface ContinuationDecision { /** Whether the handler recommends continuing. */ shouldContinue: boolean; /** Human-readable reason for the decision. */ reason: string; /** Prompt to send for continuation (only set when shouldContinue is true). */ continuationPrompt?: string; /** Current attempt number for this channel. */ attempt: number; /** Whether maxRetries has been reached. */ maxRetriesReached: boolean; } /** * StopContinuationHandler * * Manages auto-continuation state for single-agent AgentLoop channels. * Tracks per-channel attempt counts and manual stop state. */ export declare class StopContinuationHandler { private readonly config; /** Per-channel continuation attempt counts. Key = channelKey. */ private readonly attempts; /** Channels that have been manually stopped. */ private readonly stoppedChannels; constructor(config?: Partial); /** * Analyze a response and decide whether to auto-continue. * * Decision flow: * 1. If handler is disabled → return disabled decision * 2. If channel is manually stopped → return manually_stopped * 3. If response has completion marker in last 3 lines → reset + complete * 4. If max retries reached → reset + complete (safety valve) * 5. If response looks incomplete → increment attempt + continue * 6. Otherwise → normal completion */ analyzeResponse(channelKey: string, response: string): ContinuationDecision; /** * Mark a channel as manually stopped. * Prevents further auto-continuation until resetChannel is called. */ markStopped(channelKey: string): void; /** * Reset all state for a channel (attempts + stopped). */ resetChannel(channelKey: string): void; /** * Check whether the handler is enabled. */ isEnabled(): boolean; /** * Get current attempt count for a channel. */ getAttemptCount(channelKey: string): number; /** * Check whether a channel is manually stopped. */ isStopped(channelKey: string): boolean; /** * Check if the last 3 lines of a response contain a completion marker. * Case-insensitive comparison. */ private hasCompletionMarker; /** * Determine if a response appears incomplete. * * Checks two heuristics: * 1. Explicit continuation patterns (English + Korean) * 2. Truncation: response >= 1800 chars and ends without terminal punctuation */ private isIncomplete; /** * Build a continuation prompt from the tail of the previous response. * Includes the last 200 characters as context and instructs the agent * to finish with a completion marker. */ private buildContinuationPrompt; } //# sourceMappingURL=stop-continuation-handler.d.ts.map