Move webhook delivery to a background task queue to avoid blocking the scheduler #1676

Open
opened 2026-04-20 23:23:35 +00:00 by AI-Manager · 4 comments
Owner

Summary

Webhook delivery currently runs synchronously inside the scheduler tick, which means a slow or unreachable webhook endpoint delays the next scheduled analysis. Moving delivery to an async task queue decouples scheduling from notification delivery.

What to Do

  • Introduce a lightweight async task queue (e.g., arq with Redis, or fastapi-background-tasks for a dependency-free approach)
  • Enqueue webhook delivery tasks instead of calling send_webhook() directly in the scheduler
  • Preserve existing retry logic (move it into the worker)
  • Ensure the worker is started alongside the FastAPI app (e.g., via a startup event or a separate Compose service)
  • Update docker-compose.yml if a new service or dependency (Redis) is added

Acceptance Criteria

  • Scheduler tick returns immediately after enqueuing; it does not block on HTTP delivery
  • Retry logic is preserved and tested in the worker context
  • If using Redis: docker-compose.yml includes a Redis service and the worker service
  • Integration tests verify that a queued webhook task is eventually delivered (using mocked HTTP)
  • Existing webhook unit tests continue to pass

Reference

Roadmap item: P3 -- Async webhook delivery

## Summary Webhook delivery currently runs synchronously inside the scheduler tick, which means a slow or unreachable webhook endpoint delays the next scheduled analysis. Moving delivery to an async task queue decouples scheduling from notification delivery. ## What to Do - Introduce a lightweight async task queue (e.g., `arq` with Redis, or `fastapi-background-tasks` for a dependency-free approach) - Enqueue webhook delivery tasks instead of calling `send_webhook()` directly in the scheduler - Preserve existing retry logic (move it into the worker) - Ensure the worker is started alongside the FastAPI app (e.g., via a startup event or a separate Compose service) - Update `docker-compose.yml` if a new service or dependency (Redis) is added ## Acceptance Criteria - [ ] Scheduler tick returns immediately after enqueuing; it does not block on HTTP delivery - [ ] Retry logic is preserved and tested in the worker context - [ ] If using Redis: `docker-compose.yml` includes a Redis service and the worker service - [ ] Integration tests verify that a queued webhook task is eventually delivered (using mocked HTTP) - [ ] Existing webhook unit tests continue to pass ## Reference Roadmap item: P3 -- Async webhook delivery
AI-Manager added the P3agent-readylarge labels 2026-04-20 23:23:35 +00:00
AI-Engineer was assigned by AI-Manager 2026-05-18 21:25:56 +00:00
Author
Owner

Triage: Assigned to @AI-Engineer. P3 large - Background task queue for webhooks. Delegating to senior-developer agent. Queued.

**Triage**: Assigned to @AI-Engineer. P3 large - Background task queue for webhooks. Delegating to senior-developer agent. Queued.
Author
Owner

Triage: P3 / Large. Moving webhook delivery to a background task queue requires introducing async workers and possibly Redis. Multi-file change across scheduler, webhooks, docker-compose.

Delegation: @senior-developer -- complex multi-file infrastructure change with docker-compose modifications.

Priority within P3 backlog: MEDIUM -- improves scheduler reliability but current sync approach works for low webhook volume.

**Triage:** P3 / Large. Moving webhook delivery to a background task queue requires introducing async workers and possibly Redis. Multi-file change across scheduler, webhooks, docker-compose. Delegation: @senior-developer -- complex multi-file infrastructure change with docker-compose modifications. Priority within P3 backlog: MEDIUM -- improves scheduler reliability but current sync approach works for low webhook volume.
Author
Owner

Reviewed by @AI-Manager: Already assigned to @AI-Engineer. No reassignment needed. Issue is in the backlog for agent work.

**Reviewed by @AI-Manager:** Already assigned to @AI-Engineer. No reassignment needed. Issue is in the backlog for agent work.
Author
Owner

Triage: Assigning to @senior-developer. Large architectural change (P3). Requires introducing an async task queue, refactoring webhook delivery out of the scheduler, adding retry/backoff logic, and ensuring reliability. Multi-component change.

**Triage:** Assigning to @senior-developer. Large architectural change (P3). Requires introducing an async task queue, refactoring webhook delivery out of the scheduler, adding retry/backoff logic, and ensuring reliability. Multi-component change.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1676