OutboundDeliveryProtocol
Defined in the protocols module.AI Agent Protocol for durable outbound message delivery. Ensures messages sent to external channels (Telegram, Slack, Discord, etc.) are persisted before sending and can be retried on failure. This provides crash-safe at-least-once delivery for channel replies. Example usage (implementation in praisonai_bot.gateway): from praisonai.bots import OutboundQueue outbox = OutboundQueue(path=”~/.praisonai/state/outbox.sqlite”)
Enqueue before sending
key = await outbox.enqueue( idempotency_key=“msg-123”, target_channel=“telegram:12345”, payload={“text”: “Hello”, “metadata”: {…}} )Attempt delivery
success = await deliver_with_retry(adapter, channel_id, payload)Mark as sent only if successful
if success: await outbox.mark_sent(key)On restart, drain pending messages
await outbox.drain(delivery_handler)Methods
enqueue()
Persist an outbound message for delivery.
mark_sent()
Mark a message as successfully sent.
mark_failed()
Mark a message as failed.
drain()
Process pending messages.
pending_count()
Get count of pending messages awaiting delivery.
size()
Get total number of messages in queue.
purge_old()
Remove old sent messages.
Source
View on GitHub
praisonaiagents/gateway/protocols.py at line 1449
