Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

fix(backend/push): skip OS push for onboarding payloads (#12944)

Krzysztof Czerwinskic08b9774dc90
diff --git a/autogpt_platform/backend/backend/data/notification_bus.py b/autogpt_platform/backend/backend/data/notification_bus.py
index f7ab10a375..5aa9f71b52 100644
--- a/autogpt_platform/backend/backend/data/notification_bus.py
+++ b/autogpt_platform/backend/backend/data/notification_bus.py
@@ -48,6 +48,11 @@ class AsyncRedisNotificationEventBus(AsyncRedisEventBus[NotificationEvent]):
async def publish(self, event: NotificationEvent) -> None:
await self.publish_event(event, event.user_id)
+ # Skip OS push for onboarding step toasts — those are in-page only.
+ # TODO: remove once the onboarding/wallet rework lands and decides
+ # per-event whether a system notification is desired.
+ if event.payload.model_dump().get("type") == "onboarding":
+ return
# Fan out to web push subscriptions in parallel. Fire-and-forget so
# publishers never wait on the push service; held in _push_tasks so
# the task survives until completion.
diff --git a/autogpt_platform/backend/backend/data/notification_bus_test.py b/autogpt_platform/backend/backend/data/notification_bus_test.py
index 285aae1bea..6dd7ffec23 100644
--- a/autogpt_platform/backend/backend/data/notification_bus_test.py
+++ b/autogpt_platform/backend/backend/data/notification_bus_test.py
@@ -97,6 +97,31 @@ async def test_publish_fans_out_to_web_push():
mock_push.assert_awaited_once_with("user-42", event.payload)
+async def test_publish_skips_web_push_for_onboarding():
+ """Onboarding step toasts are in-page only and must NOT trigger OS push."""
+ bus = AsyncRedisNotificationEventBus()
+ event = NotificationEvent(
+ user_id="user-42",
+ payload=NotificationPayload(type="onboarding", event="step_completed"),
+ )
+
+ with (
+ patch.object(AsyncRedisNotificationEventBus, "publish_event", AsyncMock()),
+ patch(
+ "backend.data.notification_bus.send_push_for_user",
+ new_callable=AsyncMock,
+ ) as mock_push,
+ ):
+ await bus.publish(event)
+ import asyncio
+
+ for _ in range(3):
+ await asyncio.sleep(0)
+
+ mock_push.assert_not_awaited()
+
+
@pytest.mark.asyncio
async def test_publish_swallows_push_errors():
"""A failing push must not propagate or fail the publish."""