Errors & recovery

A nightly batch of 20,000 documents on DeepSeek stopped at document 12,000 with HTTP 402.

In the morning nobody knows which documents were processed.

  1. ARetry the 402 with exponential backoff, exactly as you do with 429
  2. BSplit the batch into many smaller requests so each one costs less
  3. CSwitch the whole batch to the fast model so it spends fewer tokens
  4. DCheck the estimate against the balance first; mark done documents

Answer: D

Check the estimate against the balance first; mark done documents

Why

402 means the prepaid balance ran out - no retry, model or request size fixes money. Estimate before the run and stop if balance minus a reserve does not cover it; record progress per document so a stopped run resumes where it ended instead of starting over.

More on this topic

More on Way of the Agent

Real situations from building agents - with the answer and why.

Solve a new one every day on the Path