OpenFn / OpenFn/lightning

Centralize handling AI Assistant messages failures in domain layer

Open
#3,514 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Elixir
Stars
296
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
50

Description

Description

Currently, message failure handling for AI Assistant chat is split between the worker (MessageProcessor) and Oban telemetry handlers. This means:

  • Some failures (Apollo HTTP timeout, validation errors) are handled inside the worker.
  • Others (process crash, Oban job timeout/discard) are handled via Oban telemetry events.

This works today, but it:

  • Couples core domain logic (marking messages failed) to Oban-specific events.
  • Scatters the failure-handling code across two modules.
  • Makes it harder to swap Oban for another execution mechanism in the future.
Proposal
  • Extract a domain-level helper (e.g. Lightning.AiAssistant.Messages.transition/2) that:
    • Updates message status (:processing, :success, :error, etc.).
    • Stores failure cause (timeout, HTTP error, etc.).
    • Broadcasts status changes.
  • Call this helper from both the worker and telemetry handlers.
  • Make telemetry a “catch-all” for failures not caught inside the worker.
  • Optionally store failure_category and failure_message in the DB for observability.
Benefits
  • Single source of truth for message state transitions.
  • Decouples domain logic from Oban.
  • Easier to test.
  • Easier to replace Oban in the future without touching core message logic.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the MessageProcessor worker and the Oban telemetry handlers to map their existing failure paths and status updates. Define the domain-level transition helper and confirm how both callers would use it; done means message transitions, failure causes, and broadcasts have one shared path, with any persistence and tests agreed.

Written by the indexing model from the issue text.

Assessment

Tech stack
elixir
Domain
backend
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.