/** * Classify model/runtime errors so recovery and UX can be more consistent. * * Multi-layer classification: * - Separate 'overloaded' category (529) from general server errors — shorter retry budget * - Auth errors (401) get special handling (token refresh, not retry) * - EPIPE/connection reset handled as network errors (retryable) */ export type AgentErrorCategory = 'rate_limit' | 'payment' | 'payment_rejected' | 'network' | 'timeout' | 'context_limit' | 'overloaded' | 'server' | 'auth' | 'schema' | 'unknown'; export interface AgentErrorInfo { category: AgentErrorCategory; label: 'RateLimit' | 'Payment' | 'PaymentRejected' | 'Network' | 'Timeout' | 'Context' | 'Overloaded' | 'Server' | 'Auth' | 'Schema' | 'Unknown'; isTransient: boolean; /** Max retries for this error type (overrides default). undefined = use default. */ maxRetries?: number; /** User-facing suggestion for how to recover. Appended to error message in UI. */ suggestion?: string; /** * Upstream-recommended wait time before retrying. Parsed from a * `[retry-after-ms=...]` tag the streaming client appends to the error * message when the response carries a `Retry-After` header (typically * 429 / 503). The agent loop should honor this in place of its * default exponential backoff. Capped at 10 minutes upstream so a * malicious or buggy server can't pin the agent indefinitely. */ retryAfterMs?: number; } export declare function classifyAgentError(message: string): AgentErrorInfo;