Gateway: durable outbound queue has no operator inspect/retry/purge surface (unlike the inbound DLQ), so stuck/failed agent replies are undiagnosable in production
Summary
The gateway/bot stack ships a durable, crash‑safe outbound delivery path (OutboundQueue + an outbound dead‑letter store), but it is a black box to operators. There is no way to see which agent replies are stuck or dead‑lettered, to whom, why (error/attempt count/state), and no way to retry or purge a specific one. This is asymmetric with the inbound side, which already has both a full introspection API and a first‑class operator CLI (praisonai bot dlq list|purge|replay).
For an always‑on production bot, "why didn't my user get the reply?" is a top operational question, and the outbound queue is exactly where that answer lives — yet today the only levers are opaque bulk counters and bulk purges. Adding a thin, read‑mostly operator surface (parity with the inbound DLQ) turns a silent failure mode into a diagnosable, recoverable one, with no new heavy dependencies.
Current behaviour
Inbound side — fully operable. InboundDLQ exposes per‑entry introspection and recovery, and it is wired to a CLI:
src/praisonai-bot/praisonai_bot/bots/_dlq.py—InboundDLQ.list(limit)(:217),size()(:213),replay(...)(:248),purge()(:183).src/praisonai-bot/praisonai_bot/cli/commands/bot.py:731—dlq_app = typer.Typer(help="Inspect / replay / purge the inbound dead-letter queue.")withdlq list(:747) anddlq purge(:772), mounted atapp.add_typer(dlq_app, name="dlq")(:735).praisonai gateway ...even prints a hint pointing operators at it (cli/commands/gateway.py:626-628).
Outbound side — durable but opaque. The primary durable outbox and its dead‑letter store have no per‑entry listing, no targeted retry, and no CLI at all:
src/praisonai-bot/praisonai_bot/bots/_outbox.py—class OutboundQueue(:113) exposes onlyenqueue()(:266),drain()(:428),pending_count()(:807),size()(:858),purge_old()(:863),purge()(:879). There is nolist()/peek that enumerates entries with theirtarget,status(pending/sending/recovered/failed/permanent_failure),attempts, anderror, and no targetedretry(key)(only bulkdrain/purge).src/praisonai-bot/praisonai_bot/bots/_dlq.pyhas anOutboundDLQwithlist()(:509) andreplay()(:524), but it is not wired to any CLI.- No
outboxcommand exists anywhere in the CLI (a search acrosspraisonai_bot/cli/for anoutboxTyper app / command returns nothing; only the inbounddlqapp exists).
Core protocol mirrors the same gap. OutboundDeliveryProtocol in src/praisonai-agents/praisonaiagents/gateway/protocols.py:1869 declares enqueue / mark_sent / mark_failed / drain / pending_count / purge_old — but no read/introspection method (list/stats) and no targeted retry, so even a custom backend has no contract for surfacing per‑entry state.
Net effect: when replies pile up behind a channel outage, a poison payload, or exhausted attempts (permanent_failure), an operator can see that N are pending but not which, to whom, why, and cannot retry a specific message once the channel recovers — a capability they already have for inbound messages.
Desired behaviour
Operator parity between the outbound and inbound durable paths:
- Enumerate outbound entries with
target,status,attempts,last_error,age(optionally filtered by status/target). - Retry a specific entry (or all
failed/permanent_failureentries for a target) on demand — e.g. after a channel comes back — rather than waiting for the next bulk drain. - Purge a specific entry or a filtered set (not only bulk/
purge_old). - A first‑class CLI mirroring
praisonai bot dlq, e.g.praisonai gateway outbox list|retry|purge(and the outbound DLQ exposed the same way).
Layer placement
- Primary layer: wrapper (
praisonai-bot) - Why not core: the durable SQLite implementation and the operator CLI are heavy/impl concerns that belong in
praisonai-bot; core only owns the protocol seam. Core gets a small, optional protocol addition (below), which is a secondary touch, not the primary work. - Why not tools: this is a runtime/operator operability surface for a first‑party durable component, not an agent‑callable capability the LLM invokes during a task.
- Why not plugins: it is not a lifecycle guardrail/policy/cross‑cutting hook; it is first‑party introspection of a first‑party subsystem.
- Secondary touch (optional): core — add an optional read method to
OutboundDeliveryProtocol(e.g.list_entries(...)/stats()) so alternative backends expose per‑entry state uniformly, keeping the protocol‑driven contract symmetric with the inbound path. - 3‑way surface (CLI + YAML + Python): no — this is an operator CLI plus a Python introspection API (
OutboundQueue.list()); there is no YAML surface (it inspects live runtime state, it does not configure a feature).
Proposed approach
- Extension point: protocol (small, optional read method on
OutboundDeliveryProtocol) + CLI (praisonai gateway outbox). - Add
list()/stats()(and a targetedretry(key)) toOutboundQueuemirroringInboundDLQ/OutboundDLQ; wire anoutboxTyper app inpraisonai_bot/cli/commands/gateway.py(orbot.py) exactly asdlq_appis wired today. Reuse the existing_resilience.BackoffPolicyfor retry timing, as the inbound replay path already does.
Minimal API sketch:
# _outbox.py — new, read-mostly + targeted ops (parity with InboundDLQ)
class OutboundQueue:
def list(self, *, status: str | None = None, target: str | None = None,
limit: int = 100) -> list[OutboundEntry]: ...
def stats(self) -> dict[str, int]: # {"pending": 3, "failed": 1, "permanent_failure": 2, ...}
...
async def retry(self, key: str) -> bool: # requeue one entry for the next drain
...Resolution sketch
# Before (today) — outbound path is opaque
$ praisonai gateway status
... pending outbound: 5 # 5 what? to whom? why?
# no per-entry visibility, no targeted retry — only bulk purge_old()/purge()
# After (proposed) — parity with `praisonai bot dlq`
$ praisonai gateway outbox list --status failed
KEY TARGET STATUS ATTEMPTS LAST_ERROR
a1b2c3 telegram:12345 permanent_failure 5 chat not found
d4e5f6 slack:C0abc failed 2 429 rate limited
$ praisonai gateway outbox retry d4e5f6 # channel recovered → resend on next drain
requeued 1 entry
$ praisonai gateway outbox purge a1b2c3 # drop the genuinely-dead one
purged 1 entrySeverity
Medium — messages are not lost (the durable outbox already provides crash‑safe at‑least‑once delivery), but undelivered/dead‑lettered replies are undiagnosable and not individually recoverable in production, and the capability already exists for the inbound path. It is an operability/observability gap, not a data‑loss defect.
Validation
- Read
src/praisonai-bot/praisonai_bot/bots/_outbox.py—OutboundQueue(:113) has onlyenqueue/drain/pending_count/size/purge_old/purge; no per‑entrylist/peek, no targetedretry. - Read
src/praisonai-bot/praisonai_bot/bots/_dlq.py— inboundInboundDLQhaslist/replay/purge/size(:183-248); anOutboundDLQwithlist/replay(:509/524) exists but is unwired. - Read
src/praisonai-bot/praisonai_bot/cli/commands/bot.py:731-791— the inbounddlqCLI (list/purge) exists; searchingpraisonai_bot/cli/for anyoutboxTyper app/command returns nothing. - Read
src/praisonai-agents/praisonaiagents/gateway/protocols.py:1869—OutboundDeliveryProtocolhas no read/introspection or targeted‑retry method. - Searched existing issues (durable delivery, DLQ, outbox, retry, purge): prior work covers delivery policy, wiring, and per‑platform coverage (e.g. dead‑letter thresholds, poison‑message quarantine, all‑channel durable delivery, proactive‑message durability), but none add an operator inspect/retry/purge surface for the outbound queue symmetric with the inbound DLQ CLI.
Source: MervinPraison/PraisonAI