import type { AssistantMessage } from "@bastani/pi-ai/compat"; import type { AgentSessionInternalSurface as AgentSession } from "./agent-session-methods.ts"; /** Whether an assistant error may advance the configured fallback chain. */ export declare function _isFallbackableError(this: AgentSession, message: AssistantMessage): boolean; /** * Whether the current model should be requested again. * * Fallback eligibility is broader than same-model retry eligibility. Auth and * request-incompatible failures should spend a fallback candidate, but cannot * be repaired by sending the same request again. Codex token invalidation is * also terminal for the current model while remaining fallbackable. */ export declare function _isRetryableError(this: AgentSession, message: AssistantMessage): boolean; /** * Detect a degenerate empty completion: the provider ended the stream with no * usable content and zero output tokens. Seen with github-copilot Gemini models * that emit finish_reason "stop" (or a tool-use stop) with an empty content array * and 0 output tokens, leaving the turn dead instead of producing the next step. * * These are treated as retryable so the harness re-issues the request rather than * silently stopping mid-task. Guarded tightly (no text, no tool call, no thinking, * and output === 0) so legitimate non-empty turns are never matched. * * Intentionally provider-agnostic (not gated to Copilot Gemini): a degenerate * empty turn is a transient failure for any provider. It is bounded by * `maxRetries` and falls through to normal handling on exhaustion. */ export declare function _isEmptyCompletion(this: AgentSession, message: AssistantMessage): boolean; export declare function _isSafetyRefusal(this: AgentSession, message: AssistantMessage): boolean; /** Capture the user-selected model before the first fallback in a turn. */ export declare function _beginFallbackModelScope(this: AgentSession): void; /** Finish an active fallback lifecycle before an explicit model choice. */ export declare function _clearFallbackModelScope(this: AgentSession): void; /** Finish an active fallback lifecycle without changing the selected fallback model. */ export declare function _settleFallbackModelScope(this: AgentSession): Promise; /** Handle retryable errors with exponential backoff. */ export declare function _trySwitchToFallbackModel(this: AgentSession, message: AssistantMessage): Promise; export declare function _handleRetryableError(this: AgentSession, message: AssistantMessage): Promise; export declare function abortRetry(this: AgentSession): void; /** * Wait for any in-progress retry to complete. * Returns immediately if no retry is in progress. */ export declare function waitForRetry(this: AgentSession): Promise; /** Whether auto-retry is currently in progress */ export declare function setAutoRetryEnabled(this: AgentSession, enabled: boolean): void; /** * Execute a bash command. * Adds result to agent context and session. * @param command The bash command to execute * @param onChunk Optional streaming callback for output * @param options.excludeFromContext If true, command output won't be sent to LLM (!! prefix) * @param options.operations Custom BashOperations for remote execution */ export declare const agentSessionRetryMethods: { _isRetryableError: typeof _isRetryableError; _isFallbackableError: typeof _isFallbackableError; _isEmptyCompletion: typeof _isEmptyCompletion; _isSafetyRefusal: typeof _isSafetyRefusal; _handleRetryableError: typeof _handleRetryableError; _trySwitchToFallbackModel: typeof _trySwitchToFallbackModel; _beginFallbackModelScope: typeof _beginFallbackModelScope; _clearFallbackModelScope: typeof _clearFallbackModelScope; _settleFallbackModelScope: typeof _settleFallbackModelScope; abortRetry: typeof abortRetry; waitForRetry: typeof waitForRetry; setAutoRetryEnabled: typeof setAutoRetryEnabled; }; //# sourceMappingURL=agent-session-retry.d.ts.map