Skip to content

Standardize failed outbound delivery recovery#31

Open
Dnyaneshvn wants to merge 1 commit into
inkbox-ai:mainfrom
Dnyaneshvn:fix/standardize-delivery-recovery
Open

Standardize failed outbound delivery recovery#31
Dnyaneshvn wants to merge 1 commit into
inkbox-ai:mainfrom
Dnyaneshvn:fix/standardize-delivery-recovery

Conversation

@Dnyaneshvn

Copy link
Copy Markdown

Fixes #22.

What was wrong

Outbound SMS, iMessage and email can fail after the agent has gone idle, via async delivery webhooks. The failure events were already subscribed, but dispatch only logged them, so a failure never turned into an agent turn. There was also no outbound context to correlate a failure back to its conversation, no on-channel routing for the recovery reply, and no dedup or loop protection.

What this does

  • wake the agent only on the hard failure events (text.delivery_failed, imessage.delivery_failed, message.bounced/message.failed); text.delivery_unconfirmed stays off the wake path since it's telemetry, not a hard failure
  • record outbound context on every send and correlate a failure back to the original session and thread, with a webhook contact/thread/recipient fallback; if nothing routable resolves, log and don't wake
  • deliver the recovery reply on the same channel/thread by default, reusing the existing reply path; the agent can reword to retry, switch channels with its tools, or reply exactly [SILENT] to stay quiet
  • dedup repeat webhooks (channel + event + message id, payload-hash fallback) and cap recovery per contact so a dead channel can't loop the agent

Tests

  • SMS, iMessage and email delivery failures each wake the right session
  • failure correlated back to the original session and thread
  • recovery reply delivered on the same channel/thread by default
  • exact [SILENT] suppresses the visible reply
  • text.delivery_unconfirmed does not wake the agent
  • duplicate failure webhooks don't trigger a second recovery
  • recovery send that itself fails does not wake the agent again, and recovery is capped per contact
  • startup subscribes to the failure events

Full suite green (307 tests).

Failed SMS, iMessage and email sends now wake the agent so it can retry on
the same thread. The delivery-failure events weren't woken before, so the
handlers never ran and recovery never replied on the channel that failed.

- subscribe to the hard failure events (ignore delivery_unconfirmed telemetry)
- correlate a failure back to the original conversation and thread
- reply on the failed channel by default; the agent can reword to retry,
  switch channels with its tools, or reply [SILENT] to stay quiet
- dedup repeat webhooks and cap retries so a dead channel can't loop

Fixes inkbox-ai#22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize failed outbound delivery recovery

1 participant