← Back to Pull requests

Send the product photos the AI attaches to its replies #130

Closed
unknown closed this pull request without merging on Nov 17, 2026 15:26 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 15:20 UTC
Author

Omni-AI attaches up to 3 product photos to agent replies on ai.reply.requested. Parrot used to ignore them, so customers got only the text ("Here is the photo of…") with no picture. Closes #124.

What happens now


1. The text is sent first, as before.
2. Then each photo in attachments is sent in order (at most 3; repeated URLs are dropped):
- WhatsApp: an image message with its caption.
- Messenger: the image without a caption, since Messenger can't put text on a file.
- Instagram / TikTok: skipped and logged, since files can't be sent on those channels yet.
3. Each photo is stored as the AI's image message, so the inbox shows it as a picture in the AI's bubble. No web change was needed, because the inbox already renders attachments on any message.
4. Each photo is published on messages.persisted as an AgentToUser image message, so Omni's history includes it.

Rules


  • Idempotent: each photo's request id is made from the reply's ({requestId}:media:{index}), so a redelivered event never sends a photo twice.

  • A failed photo is logged and skipped. It never fails or retries the text. If the text wasn't sent (for example, the reply window had closed), no photos are sent.

  • Safe download: the channels take the file itself, so Parrot downloads each photo first.

  • - Public https links only.
    - The address actually connected to must be public: no loopback, private, link-local/metadata or CGNAT addresses, and no redirects.
    - JPEG or PNG, checked by the file's bytes, up to WhatsApp's 5 MB.

    Changes


  • AiReplyRequested: optional Attachments (url, caption).

  • AiReplyProcessor: sends the photos after the text.

  • ConversationService.SendAgentFileAsync: sends a file as the AI (marked IsAiReply) and publishes it.

  • HttpAgentPhotoFetcher: the download, registered in MessageProcessor.
  • Testing


  • Test.Parrot.Api: 2,034 passed. The new tests cover:

  • - order and captions
    - a resend sending nothing again
    - a broken photo not blocking the rest
    - no photos when the text fails
    - the download rules and the address checks
  • Not yet tried end to end on WhatsApp.

  • Locally, catalogue photos are served from http://localhost:9000, so they'll be refused (https only). Photos send where the photo URLs are public https, such as the S3 bucket.
  • Deploy


    Rebuild/redeploy message-processor; that's where ai.reply.requested is consumed. No migrations, and no new settings.

    Diff: 309 lines (+231 / -78) across 3 files Reviewer: claude[bot] Review duration: 5m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.40) × (1 − Review Confidence (0.54)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 309 lines diff across 3 files
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 74% · Reviewer familiarity: 35%
    54%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.343
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #130"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 54% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.2% (MEDIUM) · Higher = larger blast radius
    40.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 54% · Lower = rushed or shallow review
    54%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 18.5% · Safe to merge
    18.5%