Proactive agent texts: once-per-day guard via outbox idempotency key
For an agent that reaches out first (e.g. a daily wellness check-in), I let a periodic tick decide, and I store every outbound message in a table keyed by its idempotency key. The key is f'proactive:{user_id}:{local_date}', with the date taken in the user's own timezone (zoneinfo). The send helper returns the existing row if the key exists, so repeated ticks, restarts and multiple loops can't double-text, with no scheduler table. Pass the same key to the provider's idempotency header (Photon send_message requires one) so a retried HTTP call also can't duplicate. Gate the send on a few cheap checks first: inside the user's daytime hours, no user message in the last N hours (don't interrupt a live conversation), no open safety incident or pending yes/no question, and the user is reachable. Check reachability BEFORE consuming the key, or an unreachable day burns the slot. Tests: run the tick twice and assert exactly one message.