Skip to content

Commit 6dd1d12

Browse files
authored
fix(pii): describe the mask client's retry budget the way it actually behaves (#10156)
* fix(pii): describe the mask client's retry budget the way it actually behaves * fix(pii): name the exact retryable statuses in the retry budget comment
1 parent e3070d0 commit 6dd1d12

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎apps/sim/lib/guardrails/mask-client.ts‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ const logger = createLogger('PiiMaskClient')
2626
const CHUNK_CONCURRENCY = env.PII_MASK_CHUNK_CONCURRENCY ?? 64
2727

2828
/**
29-
* Attempts per chunk for transient failures (network errors, 408/429/5xx), the
30-
* standard retry budget of the AWS and model-provider SDKs. A large payload fans
31-
* out into many chunk requests, so one blip (a dropped connection, a Presidio
32-
* worker restart) must not fail the whole redaction, but every retry re-runs the
33-
* chunk's full NER pass: a chunk that timed out or failed on its own input fails
34-
* the same way again, so more attempts only multiply the work and delay the
35-
* fail-safe. With the default jittered backoff this covers about 1.5s of failures;
36-
* a longer outage falls to the caller's fail-safe. Deterministic failures (4xx,
37-
* shape mismatches) throw immediately.
29+
* Attempts per chunk for transient failures (network errors, timeouts, and the
30+
* statuses in {@link RETRYABLE_STATUSES}), the 3-attempt default of the AWS SDK
31+
* standard retry mode and the OpenAI and Anthropic SDKs. A large payload fans out into many chunk requests, so one blip (a
32+
* dropped connection, a Presidio worker restart, a request queued behind a busy
33+
* fleet) must not fail the whole redaction. The budget stays small because every
34+
* retry re-runs the chunk's full NER pass, so a chunk that fails on its own input (a
35+
* 500 from a recognizer) only repeats that work before reaching the fail-safe.
36+
* Without a `Retry-After`, the jittered backoff spans about 1.5s; an outage
37+
* (502/503/504) that outlasts it falls to the caller's fail-safe, which with
38+
* {@link MaskPIIBatchOptions.failedChunkPlaceholder} also scrubs chunks not yet sent.
39+
* Any other status and shape mismatches throw immediately.
3840
*/
3941
const MAX_CHUNK_ATTEMPTS = 3
4042

0 commit comments

Comments
 (0)