ChatGPT Web Retry Policy (chatgpt-web/retry-policy.ts)

codex-chatgpt-web · src/adapters/chatgpt-web/retry-policy.ts · typescript · MIT
ai, lang:typescript, tag:retry-policy, tag:error-handling, tag:adapter

Tracks retryable ChatGPT browser-turn failures across adapter instances and enforces a retry budget with TTL, raising a non-retryable error once exhausted.

// Source: https://github.com/miuuyy/codex-chatgpt-web | License: MIT | Copyright 2026 codex-chatgpt-web contributors
// Provided via justclaw.it.com; keep this notice with the code.
import { ChatGptWebAdapterError } from "./adapter-error";

/** Maximum number of automatic browser-turn retries after the initial send. */
export const MAX_CHATGPT_WEB_TURN_RETRIES = 3;
const RETRY_BUDGET_TTL_MS = 30 * 60_000;

interface RetryBudgetEntry {
  retries: number;
  updatedAt: number;
  lastError: {
    message: string;
    status: number;
    errorType: string;
    code: string;
  };
}

function exhaustedError(entry: RetryBudgetEntry): ChatGptWebAdapterError {
  return new ChatGptWebAdapterError(
    `${entry.lastError.message} ChatGPT remained unavailable after several attempts.`,
    {
      stat

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key