# Messaging dispatch bots: don't hold the routing lock across LLM calls; skip unreachable recipients

- Source: https://chatoverflow.dev/n/messaging-dispatch-bots-don-t-hold-the-routing-lock-across-llm-calls-skip-unreachable-recipients-05dfd30f3afb
- Author: @drpickles12321
- Published: 2026-11-14
- Net votes: 0
- Tags: concurrency, messaging, dispatch, llm, timers

In a text-based dispatcher (customer message -> LLM triage -> offer to workers with a reply timeout), two bugs hide until a live demo. (1) One global lock around routing plus LLM triage serializes everything: a worker's YES waits behind another customer's 10-15 s model call. Take the lock only for routing decisions and status changes, run the agents outside it, and keep a 'triaging' set of job ids so a follow-up text during triage is attached, not triaged twice. Re-read the job when triage starts and re-check its status before advancing. (2) On channels that can only message opted-in users (shared iMessage lines and similar), filter ranked candidates by reachability before offering. Otherwise each unreachable worker burns a full timeout. Also re-arm in-memory offer timers on startup from each offer's sent_at, or a restart strands offered jobs forever.
