From 6301253eedaf03ff0f81367b6e5617ec45d00125 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 18 Nov 2026 09:15:52 -0800 Subject: [PATCH 1/2] fix(pii): describe the mask client's retry budget the way it actually behaves --- apps/sim/lib/guardrails/mask-client.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/apps/sim/lib/guardrails/mask-client.ts b/apps/sim/lib/guardrails/mask-client.ts index a2c2acb03a3..aa8e6931051 100644 --- a/apps/sim/lib/guardrails/mask-client.ts +++ b/apps/sim/lib/guardrails/mask-client.ts @@ -26,15 +26,17 @@ const logger = createLogger('PiiMaskClient') const CHUNK_CONCURRENCY = env.PII_MASK_CHUNK_CONCURRENCY ?? 64 /** - * Attempts per chunk for transient failures (network errors, 408/429/5xx), the - * standard retry budget of the AWS and model-provider SDKs. A large payload fans - * out into many chunk requests, so one blip (a dropped connection, a Presidio - * worker restart) must not fail the whole redaction, but every retry re-runs the - * chunk's full NER pass: a chunk that timed out or failed on its own input fails - * the same way again, so more attempts only multiply the work and delay the - * fail-safe. With the default jittered backoff this covers about 1.5s of failures; - * a longer outage falls to the caller's fail-safe. Deterministic failures (4xx, - * shape mismatches) throw immediately. + * Attempts per chunk for transient failures (network errors, timeouts, 408/429/5xx), + * the 3-attempt default of the AWS SDK standard retry mode and the OpenAI and + * Anthropic SDKs. A large payload fans out into many chunk requests, so one blip (a + * dropped connection, a Presidio worker restart, a request queued behind a busy + * fleet) must not fail the whole redaction. The budget stays small because every + * retry re-runs the chunk's full NER pass, so a chunk that fails on its own input (a + * 500 from a recognizer) only repeats that work before reaching the fail-safe. + * Without a `Retry-After`, the jittered backoff spans about 1.5s; an outage + * (502/503/504) that outlasts it falls to the caller's fail-safe, which with + * {@link MaskPIIBatchOptions.failedChunkPlaceholder} also scrubs chunks not yet sent. + * Other 4xx and shape mismatches throw immediately. */ const MAX_CHUNK_ATTEMPTS = 3 From 6d8b79cca0af2fc9db071f12a7615418bad1c3c1 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Wed, 18 Nov 2026 09:24:27 -0800 Subject: [PATCH 2/2] fix(pii): name the exact retryable statuses in the retry budget comment --- apps/sim/lib/guardrails/mask-client.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/sim/lib/guardrails/mask-client.ts b/apps/sim/lib/guardrails/mask-client.ts index aa8e6931051..e5543996186 100644 --- a/apps/sim/lib/guardrails/mask-client.ts +++ b/apps/sim/lib/guardrails/mask-client.ts @@ -26,9 +26,9 @@ const logger = createLogger('PiiMaskClient') const CHUNK_CONCURRENCY = env.PII_MASK_CHUNK_CONCURRENCY ?? 64 /** - * Attempts per chunk for transient failures (network errors, timeouts, 408/429/5xx), - * the 3-attempt default of the AWS SDK standard retry mode and the OpenAI and - * Anthropic SDKs. A large payload fans out into many chunk requests, so one blip (a + * Attempts per chunk for transient failures (network errors, timeouts, and the + * statuses in {@link RETRYABLE_STATUSES}), the 3-attempt default of the AWS SDK + * standard retry mode and the OpenAI and Anthropic SDKs. A large payload fans out into many chunk requests, so one blip (a * dropped connection, a Presidio worker restart, a request queued behind a busy * fleet) must not fail the whole redaction. The budget stays small because every * retry re-runs the chunk's full NER pass, so a chunk that fails on its own input (a @@ -36,7 +36,7 @@ const CHUNK_CONCURRENCY = env.PII_MASK_CHUNK_CONCURRENCY ?? 64 * Without a `Retry-After`, the jittered backoff spans about 1.5s; an outage * (502/503/504) that outlasts it falls to the caller's fail-safe, which with * {@link MaskPIIBatchOptions.failedChunkPlaceholder} also scrubs chunks not yet sent. - * Other 4xx and shape mismatches throw immediately. + * Any other status and shape mismatches throw immediately. */ const MAX_CHUNK_ATTEMPTS = 3