Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.8k
fix(providers): route 6-10MB attachments to the provider large-file path#6232
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
2a80121
fix(providers): route 6-10MB attachments to the provider large-file path
waleedlatif1 8549328
chore(deps): upgrade @google/genai to 2.13.0 and @anthropic-ai/sdk to…
waleedlatif1 3786320
chore(deps): upgrade openai to 7.0.0
waleedlatif1 2ba228a
fix(providers): correct defects found auditing the attachment and SDK…
waleedlatif1 7790d30
fix(providers): keep every attachment that works today working
waleedlatif1 ade82d4
fix(providers): drop the provider ceiling changes and close the audit…
waleedlatif1 092ac94
fix(providers): report attachment limits in the unit vendors publish
waleedlatif1 8bb7b3e
fix(providers): derive the limit unit from the ceiling it belongs to
waleedlatif1 f1889ad
fix(providers): stop an over-limit size rendering as the limit itself
waleedlatif1 0356912
fix(providers): order the attachment failure reason by how general th…
waleedlatif1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -53,10 +53,15 @@ import { stringifyJSON } from '@/executor/utils/json' | ||
| import { resolveVertexCredential } from '@/executor/utils/vertex-credential' | ||
| import { executeProviderRequest } from '@/providers' | ||
| import { | ||
| INLINE_ATTACHMENT_THRESHOLD_BYTES, | ||
| formatAttachmentSizes, | ||
| getProviderFileStrategy, | ||
| shouldUseLargeFilePath, | ||
| supportsFileAttachments, | ||
| } from '@/providers/attachments' | ||
| import { | ||
| canUseProviderLargeFilePath, | ||
| getInlineHydrationMaxBytes, | ||
| } from '@/providers/file-attachments.server' | ||
| import { isAutoModel, SIM_AUTO_MODEL_ID } from '@/providers/models' | ||
| import { getProviderFromModel, transformBlockTool } from '@/providers/utils' | ||
| import type { SerializedBlock } from '@/serializer/types' | ||
| @@ -946,6 +951,8 @@ export class AgentBlockHandler implements BlockHandler { | ||
| const requestId = ctx.executionId || ctx.workflowId || 'agent-files' | ||
| const nextMessages = [...messages] | ||
| const inlineMaxBytes = getInlineHydrationMaxBytes(providerId) | ||
| for (let messageIndex = 0; messageIndex < messages.length; messageIndex++) { | ||
| const message = messages[messageIndex] | ||
| if (!message.files?.length) { | ||
| @@ -963,15 +970,37 @@ export class AgentBlockHandler implements BlockHandler { | ||
| allowLargeValueWorkflowScope: ctx.allowLargeValueWorkflowScope, | ||
| userId: ctx.userId, | ||
| logger, | ||
| maxBytes: INLINE_ATTACHMENT_THRESHOLD_BYTES, | ||
| maxBytes: inlineMaxBytes, | ||
| }) | ||
| const missingFile = hydratedFiles.find( | ||
| (file) => !file.base64 && !shouldUseLargeFilePath(file, providerId) | ||
| (file) => | ||
| !file.base64 && | ||
| !(canUseProviderLargeFilePath(providerId) && shouldUseLargeFilePath(file, providerId)) | ||
| ) | ||
| if (missingFile) { | ||
| const { size: sizeMB, limit: inlineMB } = formatAttachmentSizes( | ||
| missingFile.size, | ||
| inlineMaxBytes | ||
| ) | ||
| const oversized = Number.isFinite(missingFile.size) && missingFile.size > inlineMaxBytes | ||
| /** | ||
| * Ordered by how general the cause is. A provider with no upload path at all cannot be | ||
| * helped by changing the file, and a deployment with no object storage cannot reach any | ||
| * upload path whatever the file is — so both outrank the format-specific case. Leading | ||
| * with the generated-document arm blamed the document on providers that have no upload | ||
| * path for anything, and on hosts whose only real problem was unconfigured storage. | ||
| */ | ||
| const reason = | ||
| getProviderFileStrategy(providerId) === 'inline' | ||
| ? `provider "${providerId}" has no large-file upload path` | ||
| : !canUseProviderLargeFilePath(providerId) | ||
| ? 'this deployment has no cloud file storage for the large-file upload path' | ||
| : `a generated document cannot use the large-file path for provider "${providerId}", because a signed URL points at the generation source rather than the rendered file` | ||
| throw new Error( | ||
| `File "${missingFile.name}" could not be read for provider "${providerId}". The file may exceed the attachment size limit or may no longer be accessible.` | ||
| oversized | ||
| ? `File "${missingFile.name}" (${sizeMB}MB) exceeds the ${inlineMB}MB inline attachment limit, and ${reason}.` | ||
| : `File "${missingFile.name}" could not be read for provider "${providerId}". The file may no longer be accessible.` | ||
cursor[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5 apps/sim/lib/copilot/tools/server/workflow/edit-workflow/validation.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34 apps/sim/lib/uploads/utils/user-file-base64.server.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.