Attempt And Age Dead Letter Policy • AI Agent SDK
AttemptAndAgeDeadLetterPolicy: Default dead-letter policy: require BOTH attempt-exhaustion AND age.
AttemptAndAgeDeadLetterPolicy
Defined in the protocols module.
AI Agent
Default dead-letter policy: require BOTH attempt-exhaustion AND age.
Distinguishes a poison message (fails repeatedly over a long time) from a transient outage (fails a few times quickly, then recovers). A recoverable/transient failure is dead-lettered only once it satisfies
both:
- `
attempts >= max_attempts`, and - `
age >= min_age_seconds` (wall-clock age since first receipt).
Until an entry is genuinely old it keeps retrying under capped backoff rather than being discarded, so a brief channel incident results in delayed-but-delivered messages rather than a DLQ full of manual-replay work. A truly poisoned entry still dead-letters — it keeps failing past both thresholds.
An error whose `error_class is known-permanent (see :data:PERMANENT_ERROR_CLASSES` — a revoked credential or a permanently invalid target) short-circuits to dead-letter immediately regardless of age, since retrying can never recover it.
`min_age_seconds=0` restores the legacy attempt-count-only behaviour, keeping the knob fully backward-compatible for callers that opt in.
Example::
AttemptAndAgeDeadLetterPolicy(max_attempts=5, min_age_seconds=6*3600)Constructor
intNo description available.
intNo description available.
Properties
intNo description available.
Methods
Source
View on GitHubpraisonaiagents/gateway/protocols.py at line 5480