> ## 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**](../modules/protocols) module.

<Badge color="blue">AI Agent</Badge>

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

<ParamField query="max_attempts" type="int" required={false} default="5">
  No description available.
</ParamField>

<ParamField query="min_age_seconds" type="int" required={false} default="DEFAULT_MIN_AGE_SECONDS">
  No description available.
</ParamField>

## Properties

<ResponseField name="DEFAULT_MIN_AGE_SECONDS" type="int">
  No description available.
</ResponseField>

## Methods

<CardGroup cols={2}>
  <Card title="should_dead_letter()" icon="function" href="../functions/AttemptAndAgeDeadLetterPolicy-should_dead_letter">
    Instance method.
  </Card>
</CardGroup>

## Source

<Card title="View on GitHub" icon="github" href="https://github.com/MervinPraison/PraisonAI/blob/main/src/praisonai-agents/praisonaiagents/gateway/protocols.py#L3867">
  `praisonaiagents/gateway/protocols.py` at line 3867
</Card>
