Skip to content

Conversation

@satwikkansal
Copy link
Collaborator

@satwikkansal satwikkansal commented Aug 31, 2025

Description

  • Adds support for +local routing logic at email routing layer to allow for testing
  • Reduces duplication of context, input prompts are more token efficient now
  • Removes certain logs
  • Removes whitelist requirements for /suggestions endpoint
  • Add risk, spam, and AI Authorship analysis to the suggestions API
  • Add a new field called overview to the suggestions API

The new suggestions response looks like this now

[
    {
        "email_identified": "email-001",
        "user_email_id": "satwikkadsal@mydomadfsfdin.com",
        "overview": "A suspicious lottery win email requests bank details, likely a phishing attempt requiring immediate caution and verification.",
        "suggestions": [
            {
                "suggestion_title": "Verify scam claims",
                "suggestion_id": "2bdfda42-a07e-40c2-8674-d4428c5c9b6c",
                "suggestion_to_email": "fact-check@mxgo.ai",
                "suggestion_cc_emails": [],
                "suggestion_email_instructions": "Check if this lottery claim is a known scam and verify legitimacy of sender"
            },
            {
                "suggestion_title": "Research sender",
                "suggestion_id": "370eeb84-5d9c-45bf-ac6f-f05535febd5d",
                "suggestion_to_email": "background-research@mxgo.ai",
                "suggestion_cc_emails": [],
                "suggestion_email_instructions": "Research the sender's company and email domain for legitimacy and reputation"
            },
            {
                "suggestion_title": "Summarize email",
                "suggestion_id": "ca0759ea-03af-482e-9b90-3bc2fec13622",
                "suggestion_to_email": "summarize@mxgo.ai",
                "suggestion_cc_emails": [],
                "suggestion_email_instructions": ""
            },
            {
                "suggestion_title": "Ask anything",
                "suggestion_id": "18f226ad-d81b-4b0f-9535-7449bba8a6a9",
                "suggestion_to_email": "ask@mxgo.ai",
                "suggestion_cc_emails": [],
                "suggestion_email_instructions": ""
            }
        ],
        "risk_analysis": {
            "risk_prob_pct": 45,
            "risk_reason": "Request for bank details after lottery win claim suggests potential fraud",
            "spam_prob_pct": 65,
            "spam_reason": "Lottery win claim with generic greeting and unsolicited offer",
            "ai_likelihood_pct": 40,
            "ai_explanation": "Some minor spelling errors and informal tone suggest human authorship over AI"
        }
    }
]

Checklist

  • I have created an issue for this change (not mandatory for small changes)
  • My changes are to-the-point
  • Code is styled as the rest of the codebase and linting passes
  • I have tested my changes locally and they work as expected
  • I have updated the documentation (if needed)
  • I have reviewed the code myself once and I don't see any issues

Additional Notes

Any additional context or notes for reviewers.

@satwikkansal satwikkansal requested a review from Copilot August 31, 2025 19:18
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 31, 2025

Deploying mxtoai-backend with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4550671
Status: ✅  Deploy successful!
Preview URL: https://8f514a7e.mxtoai-backend.pages.dev
Branch Preview URL: https://enhancements.mxtoai-backend.pages.dev

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds email handle normalization, risk analysis capabilities, and improves the suggestion system. The changes enhance email processing with security analysis and streamline suggestion generation while supporting local development routing.

  • Enhanced email handle processing to strip plus-notation suffixes (e.g., user+tag@domain.comuser@domain.com)
  • Added comprehensive risk analysis system to evaluate phishing, spam, and AI authorship likelihood
  • Improved suggestion system with overview generation and parallel processing of suggestions and risk analysis

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pyproject.toml Updates smolagents dependency from 1.16.1 to 1.21.2
mxgo/validators.py Adds email handle normalization to strip plus-notation suffixes
mxgo/tasks.py Adds same email handle normalization logic for task processing
mxgo/suggestions.py Major enhancement adding risk analysis, overview generation, and parallel processing
mxgo/schemas.py Adds RiskAnalysisResponse model and overview field to EmailSuggestionResponse
mxgo/api.py Removes whitelist validation and debug logging from suggestions endpoint
mxgo/agents/email_agent.py Adds TokenUsage monkey patch and removes unused code
email-worker/src/worker.js Adds local development routing based on '+local' recipient suffix

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gautamp8
Copy link
Collaborator

gautamp8 commented Sep 1, 2025

LGTM overall, few minor comments.

@satwikkansal satwikkansal merged commit ce42fd1 into master Sep 4, 2025
6 of 7 checks passed
@BhaveshKukreja29 BhaveshKukreja29 deleted the enhancements branch January 12, 2026 05:14
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.

3 participants