> ## 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.

# drain • AI Agent SDK

> drain: Process pending messages.

# drain

AsyncMethod

> This is a method of the [**OutboundDeliveryProtocol**](https://praison.ai/docs/sdk/reference/praisonaiagents/classes/OutboundDeliveryProtocol.md) class in the [**protocols**](https://praison.ai/docs/sdk/reference/praisonaiagents/modules/protocols.md) module.

Process pending messages.

Called on startup to retry unsent messages. Messages are processed
oldest-first to maintain order.

## Signature

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
async def drain(sender: Callable[[str, Dict[str, Any]], Awaitable[bool]], limit: Optional[int]) -> tuple[int, int]
```

## Parameters

**sender** `Callable` *required*

Async function that attempts delivery. Should return True on success, False to retry later.

**limit** `Optional[int]`

Optional max messages to process

### Returns

**Returns** `tuple[int, int]`

Tuple of (succeeded, failed) counts

## Source

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


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