> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) 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**:

1. `attempts &gt;= max_attempts`, and
2. `age &gt;= 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::

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
AttemptAndAgeDeadLetterPolicy(max_attempts=5, min_age_seconds=6*3600)
```

## Constructor

**max\_attempts** `int` (default: 5)

No description available.

**min\_age\_seconds** `int` (default: DEFAULT\_MIN\_AGE\_SECONDS)

No description available.

## Properties

**DEFAULT\_MIN\_AGE\_SECONDS** `int`

No description available.

## Methods

> [card] [should\_dead\_letter()](https://praison.ai/docs/sdk/reference/praisonaiagents/functions/AttemptAndAgeDeadLetterPolicy-should_dead_letter.md)
>
> Instance method.

## Source

> [card] [View on GitHub](https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L5480)
>
> `praisonaiagents/gateway/protocols.py` at line 5480


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.