/** * When the LLM stream completes with stopReason "error" (e.g. undici "fetch failed" * to the provider API), pi-agent-core does not throw — it appends an error assistant * message. This module detects transient network-style failures and retries the turn * via Agent.continue() after stripping the failed assistant message. */ import type { Agent, AgentMessage } from '@earendil-works/pi-agent-core'; export declare function isTransientLlmErrorMessage(message: string): boolean; export declare function getLastAssistantMessage(messages: AgentMessage[]): AgentMessage | undefined; /** Raw provider/LLM error from the last failed assistant message, if any. */ export declare function getAssistantTurnErrorMessage(agent: Agent): string | undefined; /** After waitForIdle + transient retries, true if the last assistant turn ended in error. */ export declare function isAssistantTurnFailed(agent: Agent): boolean; /** User or client aborted the assistant turn — do not try another model. */ export declare function isAssistantTurnAborted(agent: Agent): boolean; /** * Remove trailing assistant messages that ended in error/aborted (typically one). */ export declare function stripTrailingErrorAssistantMessages(messages: AgentMessage[]): AgentMessage[]; export interface RetryTransientTurnOptions { /** Extra turns after a failed assistant message (default 2). */ maxContinues?: number; sessionKey: string; log: { warn: (obj: Record, msg: string) => void; }; } /** * After waitForIdle(), call this to optionally re-run the last user turn when the * assistant message only contains a transient provider/network error. */ export declare function maybeRetryTurnAfterTransientLlmFailure(agent: Agent, options: RetryTransientTurnOptions): Promise;