@adcp/sdk API Reference - v10.0.1
    Preparing search index...

    Class BuyerRetryPolicy

    Buyer-side retry policy with operator-grade defaults per AdCP error code.

    import { decideRetry, type RetryDecision } from '@adcp/sdk';

    try {
    return await callAgent({ idempotency_key: key, ... });
    } catch (e) {
    const error = extractAdcpError(e);
    const decision = decideRetry(error, { attempt });

    if (decision.action === 'retry') {
    await sleep(decision.delayMs);
    return callAgent({ idempotency_key: key, ... }); // SAME key
    }
    if (decision.action === 'mutate-and-retry') {
    // Apply correction (decision.field, decision.suggestion), fresh key.
    return callAgent({ idempotency_key: crypto.randomUUID(), ... });
    }
    throw new Error(`Escalate: ${decision.reason}${decision.message}`);
    }
    Index

    Constructors

    Methods

    Constructors

    • Parameters

      • opts: {
            overrides?: Partial<Record<StandardErrorCode, RetryDecisionOverride>> & Record<
                string,
                RetryDecisionOverride,
            >;
            unknownCode?: "escalate"
            | "mutate";
        } = {}
        • Optionaloverrides?: Partial<Record<StandardErrorCode, RetryDecisionOverride>> & Record<
              string,
              RetryDecisionOverride,
          >

          Per-code override functions. Keyed by error code (typed as Partial<Record<ErrorCode, RetryDecisionOverride>> so typos like POLICY_VIOLATIN fail compile). Returns null to fall through to the default policy.

        • OptionalunknownCode?: "escalate" | "mutate"

          What to do when the error code is not in the standard vocabulary AND has no per-code override. 'escalate' (default) is the safer choice for unknown vendor codes — buyer surfaces to user. 'mutate' lets the buyer attempt a generic correction-and-retry.

      Returns BuyerRetryPolicy

    Methods