#5323·PraisonAI

Gateway push has reliable delivery but no notification policy — no categories, quiet hours, detail/privacy levels, or per-recipient preferences

Author: MervinPraisonCreated Sep 26, 2026Updated Sep 26, 2026
Labelsquestionclaude

Summary

The gateway can deliver push notifications reliably, but it has no notion of a notification policy: there is no category taxonomy (e.g. approval needed vs agent finished vs agent asked a question), no per-recipient preferences, no quiet-hours window, and no detail/privacy level controlling how much message content leaves the gateway in a notification. For a gateway/bot that runs long or autonomous work, the async "call me back when it matters" loop is exactly what makes it usable — and today it is all-or-nothing: a recipient either receives every push or silences the channel entirely, and whatever content is pushed is pushed verbatim. This is a first-class ease-of-use and safety gap for a world-class gateway.

Current behaviour

The push stack today is transport + delivery-guarantee only:

  • Core exposes a transport contract, not a policy one — src/praisonai-agents/praisonaiagents/push/__init__.py re-exports PushTransportProtocol and ChannelMessage; concrete transports are WebSocketTransport / PollingTransport. push/protocols.py defines PushTransportProtocol (how bytes reach a device), nothing about whether or what to notify.
  • src/praisonai-bot/praisonai_bot/gateway/push_delivery.py — "Push Delivery Guarantee Manager … at-least-once message delivery with ack tracking and retry logic." Durable SQLite outbox (SqlitePushStore), acks, retries. This is delivery reliability, not user-facing policy.
  • src/praisonai-bot/praisonai_bot/gateway/push_channels.py — subscription management only (register/unregister a device/subscription).
  • push_presence.py / push_polling.py — presence tracking and polling transport.

There is no NotificationCategory, quiet-hours evaluation, detail level, or per-recipient preference anywhere in the gateway or core: a repository-wide search across praisonai-bot/praisonai_bot/ and praisonaiagents/gateway/ for quiet.?hour|notification.?categor|detail.?level|preference|snooze returns no notification-policy code (only an unrelated "do not disturb it" comment in bots/_ingress.py).

The lifecycle events that should drive categories already exist in core but are not mapped to any notification decision — praisonaiagents/hooks/types.py:HookEvent has AFTER_AGENT (agent finished), the exec-approval flow (praisonai_bot/gateway/exec_approval.py) raises human-in-the-loop approval requests, and streaming/events.py:StreamEventType.STREAM_END marks completion. Nothing turns these into "notify recipient R, if their prefs allow this category now, at their chosen detail level".

Desired behaviour

A recipient (operator/user/device) can express, and the gateway can enforce, a notification policy:

  • Categories — subscribe/unsubscribe per event class, e.g. approval_requested, agent_finished, agent_question, human_mentioned, scheduled_task_failed, background_task_failed.
  • Quiet hours — a per-recipient time window (with timezone) during which non-urgent categories are suppressed or deferred; urgent categories (e.g. approval_requested) may override.
  • Detail level — private (a bare "you have activity"), identified (which agent/session, no content), or detailed (content included), so sensitive transcript content need not leave the gateway in a device notification.
  • Per-recipient preferences — stored durably alongside the existing subscription record and honoured at delivery time; a sensible default policy applies when a recipient has set nothing.

Layer placement

  • Primary layer: core (praisonaiagents)
  • Why not core: core is the right home — the category taxonomy, the per-recipient preference schema, and the pure decision function evaluate(event, prefs, now) -> NotificationDecision (quiet-hours maths + category filter + detail-level redaction) are dependency-free protocol/policy code, exactly what the protocol-driven core is for.
  • Why not wrapper (as primary): the wrapper/praisonai-bot is the right place to enforce the decision inside push_delivery.py, to persist preferences next to subscriptions, and to expose CLI/YAML — but that is a secondary touch. Putting the taxonomy + schema + evaluator only in the bot package would deny the same policy to other notifiers (scheduler completions, background-job alerts) and break protocol-driven-core.
  • Why not tools: notification preferences are not an agent-callable capability; the agent does not invoke them during a task.
  • Why not plugins: quiet hours / categories / detail levels are always-needed gateway behaviour, not an optional cross-cutting guardrail; a plugin may extend policy, but the base contract must ship in core.
  • Secondary touch: wrapper — enforcement in praisonai_bot/gateway/push_delivery.py, preference store beside push_channels.py, praisonai gateway CLI, and a notifications: block in gateway.yaml.
  • 3-way surface (CLI + YAML + Python): yes.

Proposed approach

  • Extension point: a new core protocol + pure policy in praisonaiagents/push/ (or praisonaiagents/gateway/): NotificationCategory enum, NotificationPreference dataclass, and NotificationPolicyProtocol with a pure evaluate(...). The gateway's delivery manager consults it before every push; the transport layer stays unchanged.
  • Minimal API sketch:
python
# praisonaiagents/push/policy.py  (core — pure, no heavy deps)
class NotificationCategory(str, Enum):
    APPROVAL_REQUESTED = "approval_requested"
    AGENT_FINISHED = "agent_finished"
    AGENT_QUESTION = "agent_question"
    HUMAN_MENTIONED = "human_mentioned"
    SCHEDULED_TASK_FAILED = "scheduled_task_failed"
    BACKGROUND_TASK_FAILED = "background_task_failed"

class DetailLevel(str, Enum):
    PRIVATE = "private"; IDENTIFIED = "identified"; DETAILED = "detailed"

@dataclass
class NotificationPreference:
    categories: set[NotificationCategory]           # opted-in categories
    quiet_hours: tuple[time, time] | None = None    # local window
    timezone: str = "UTC"
    detail: DetailLevel = DetailLevel.IDENTIFIED
    urgent_overrides_quiet: bool = True

@dataclass
class NotificationDecision:
    send: bool
    reason: str
    redacted_content: str | None                    # per detail level

def evaluate(category, prefs, *, now, is_urgent, content) -> NotificationDecision: ...

Resolution sketch

python
# Before (today): push is delivered if a subscription exists — no policy.
push_delivery.deliver(recipient, ChannelMessage(text=full_transcript_tail))
# Every subscribed device gets everything, verbatim, at any hour.

# After (proposed): gateway consults the policy before delivery.
decision = notification_policy.evaluate(
    NotificationCategory.AGENT_FINISHED,
    prefs=store.preferences_for(recipient),
    now=datetime.now(tz=...),
    is_urgent=False,
    content=full_transcript_tail,
)
if decision.send:
    push_delivery.deliver(recipient, ChannelMessage(text=decision.redacted_content))
# Recipient in quiet hours, or not subscribed to agent_finished, is skipped;
# a 'private' recipient gets "Activity in session X" instead of the transcript.

CLI/YAML surface (secondary):

yaml
# gateway.yaml
notifications:
  defaults: { detail: identified, categories: [approval_requested, agent_question] }
  recipients:
    "operator:alice":
      categories: [approval_requested, agent_finished, agent_question]
      quiet_hours: "22:00-07:30"
      timezone: "Europe/London"
      detail: detailed

Severity

High — for a gateway that runs long or autonomous tasks, unusable notifications (spam vs silence, and content leaking to lock-screens) directly undermine the product's core async-loop value and its safety story. No data loss, so not Critical.

Validation

  • Confirmed the push stack is transport + delivery-guarantee only: praisonaiagents/push/__init__.py (PushTransportProtocol, ChannelMessage), push/protocols.py; praisonai_bot/gateway/push_delivery.py (at-least-once/ack/retry), push_channels.py (subscription management), push_presence.py, push_polling.py.
  • Confirmed absence of any notification-policy code via repository-wide search across praisonai-bot/praisonai_bot/ and praisonaiagents/gateway/ for quiet.?hour|notification.?categor|detail.?level|preference|snooze — no matches (only an unrelated comment in bots/_ingress.py).
  • Confirmed the driving lifecycle events already exist and are unmapped to notifications: praisonaiagents/hooks/types.py:HookEvent (AFTER_AGENT), praisonai_bot/gateway/exec_approval.py (approval requests), praisonaiagents/streaming/events.py:StreamEventType.STREAM_END.