-
Notifications
You must be signed in to change notification settings - Fork 278
feat: email attachment support for agent incoming emails #2445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Adds the ability for agents to receive and process email attachments when invoked through the incoming email feature: - Add EmailAttachment interface with fields for id, name, contentType, size, contentBase64, isInline, and contentId - Update IncomingEmail interface to include optional attachments array - Add getAttachments method to AgentIncomingEmailProvider interface - Implement attachment fetching in OutlookEmailProvider using Microsoft Graph API - Update parseWebhookNotification to automatically fetch attachments - Add size constraints: 10MB individual limit, 25MB total per message - Add comprehensive tests for attachment functionality https://claude.ai/code/session_013gpmZvxDAu8mZdRS2Vpmb9
|
|
There was a problem hiding this 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 comprehensive email attachment handling to the incoming email provider, enabling agents to receive and process file attachments from incoming emails through the Microsoft Graph API. The implementation includes size limits, attachment type filtering, and error resilience to ensure robust handling of email attachments.
Changes:
- Added attachment-related constants for size limits and count restrictions
- Extended type definitions to support email attachments with metadata and content
- Implemented attachment fetching in the Outlook provider with comprehensive validation and error handling
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
platform/backend/src/types/incoming-email.ts |
Added EmailAttachment interface and extended IncomingEmail and provider interface to support attachments |
platform/backend/src/agents/incoming-email/outlook-provider.ts |
Implemented getAttachments() method with size validation, type filtering, and integrated attachment fetching into email processing |
platform/backend/src/agents/incoming-email/outlook-provider.test.ts |
Added 10 comprehensive test cases covering attachment fetching scenarios, edge cases, and error handling |
platform/backend/src/agents/incoming-email/constants.ts |
Defined attachment size limits and count restrictions as constants |
Comments suppressed due to low confidence (1)
platform/backend/src/agents/incoming-email/outlook-provider.ts:1
- The test expects
contentIdto beundefinedwhen the API returnsnull, but the implementation at line 962 directly assignsattachment.contentIdwithout convertingnulltoundefined. This will cause the test assertion to fail. Update line 962 to handle null values:contentId: attachment.contentId || undefined
import crypto from "node:crypto";
|
|
||
| const emailAttachment: EmailAttachment = { | ||
| id: attachment.id, | ||
| name: attachment.name || "unnamed", |
Copilot
AI
Jan 27, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the fallback value 'unnamed' for missing attachment names could cause confusion when multiple attachments lack names. Consider using a more descriptive fallback like 'attachment-{id}' or 'untitled-attachment' to help distinguish between unnamed attachments.
| name: attachment.name || "unnamed", | |
| name: | |
| attachment.name || | |
| (attachment.id ? `attachment-${attachment.id}` : "untitled-attachment"), |
|
Claude finished @joeyorlando's task in 50s —— View job Code Review: Email Attachment Support
Overall, this is a well-implemented feature with good error handling and comprehensive test coverage. I found a few issues that should be addressed: Issues Found1. Bug:
|
Playwright test resultsDetails
Flaky testsapi › api/mcp-gateway.spec.ts › MCP Gateway - External MCP Server Tests › should invoke internal-dev-test-server tool successfully Skipped testsapi › api/chat-models.spec.ts › Chat Models Cache Invalidation API › should actually clear the cache so next request fetches fresh data |
Summary
This PR adds comprehensive email attachment handling to the incoming email provider, enabling agents to receive and process file attachments from incoming emails through the Microsoft Graph API.
Key Changes
New Constants (
constants.ts):MAX_ATTACHMENT_SIZE: 10MB limit per individual attachmentMAX_TOTAL_ATTACHMENTS_SIZE: 25MB limit for all attachments per email (respects Microsoft Graph API limits)MAX_ATTACHMENTS_PER_EMAIL: 20 attachment limit per email to prevent excessive processingNew Type (
types/incoming-email.ts):EmailAttachmentinterface with properties: id, name, contentType, size, contentBase64, isInline, contentIdIncomingEmailinterface to include optionalattachmentsfieldProvider Implementation (
outlook-provider.ts):getAttachments()method that fetches attachment metadata and optionally content from Microsoft Graph APIhasAttachmentsfield to message selection for efficient filteringComprehensive Test Coverage (
outlook-provider.test.ts):Implementation Details
https://claude.ai/code/session_013gpmZvxDAu8mZdRS2Vpmb9