## TL;DR

The merge fails, the agent retries immediately, it fails again, forever, burning API calls and log space. Add exponential backoff between attempts, cap the retries, and move persistently failing pairs to a dead-letter list for human review. Retrying a deterministic failure is not persistence; it is a loop.

## Error

```text
(No error; the symptom is the same merge attempted hundreds of times with identical failure.)
```

## Steps

1. Confirm the failure is deterministic: the error is the same every attempt (data problem, not transient). Expected: you know backoff alone will not fix it.
2. Add exponential backoff (seconds, then minutes) between retries, with a max attempt count. Expected: the loop slows and then stops.
3. After the max attempts, move the pair to a dead-letter list with the error recorded. Expected: the pair waits for a human, not for attempt 400.
4. Fix the underlying data issue for dead-lettered pairs (master selection, child limits, validation). Expected: pairs become mergeable.
5. Re-queue fixed pairs manually. Expected: controlled retry, not a loop.

## When to use

- Merges retry identically with no delay.
- An agent has no retry cap.
- API usage spikes from retry storms.

## When not to use

- Transient failures (those deserve retries with backoff).
- First-attempt merge failures (fix the merge).

## Tool compatibility

- Agent retry logic; dead-letter storage.
- Salesforce merge API error classification.

## Variant phrasings

### merge retried forever

Cap retries; dead-letter the pair.

### no backoff on merge failure

Add exponential backoff.

## Why it happens

Retry logic written for transient errors meets a deterministic data error. The code cannot distinguish them, so it retries forever.

## Edge cases

- Classify errors: transient (retry with backoff) vs deterministic (dead-letter fast).
- Backoff needs jitter; synchronized retries from parallel workers thunder.
- Dead-letter review needs a cadence, or the list grows forever.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_i648-kgNC43lCEVS5ExBAw
