You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SaveFilesAsArtifactsPlugin: Can't handle too big files (PDFs) #3751
Describe the bug
Using SaveFilesAsArtifactsPlugin works fine until the file gets too big.
Uploading a PDF with around 5MB - ✅
Uploading a PDF with around 50MB - ❌
root_agent = Agent(
name="Super Cool Agent",
model="gemini-2.5-flash",
description="Analyzing the uploaded PDF",
instruction="Analyze the uploaded PDF and give the user a short summary",
)
app = App(
name='Super_Cool_Agent',
root_agent=root_agent,
plugins=[SaveFilesAsArtifactsPlugin()],
)
Expected behavior
I should be able to upload all files or get a proper error message.
Desktop (please complete the following information):
OS: macOS
Python version(python -V): 3.14
ADK version(pip show google-adk): 1.19.0
Model Information:
Are you using LiteLLM: No
Which model is being used(e.g. gemini-2.5-pro): gemini-2.5-flash
As suggested, I’ve implemented an approach that uses file-size routing so the plugin now transparently supports files of all sizes without imposing a strict 20MB limit.
Summary of the Solution
I added automatic file-size detection and routing to ensure the correct upload path is used:
≤ 20MB → processed via inline_data (fast path, no upload required)
20MB–2GB → automatically uploaded via the Files API
> 2GB → proactively rejected with a clear, user-friendly error message explaining the API limit
Additionally, the plugin now:
Converts Files API URIs into file_data references automatically.
Provides detailed feedback including filename, actual size, API limits, and next steps.
Handles Files API failures gracefully with actionable messaging.
Prevents the previous cryptic 400 INVALID_ARGUMENT error from reaching users.
@Smponias The plugin sends file data inline to the Gemini API which has a ~20MB limit — that's why your 50MB PDF hits a 400 INVALID_ARGUMENT.
There's no size validation in save_files_as_artifacts_plugin.py currently.
PR #3781 adds size-based routing (≤20MB inline, 20MB–2GB via Files API) but hasn't been merged yet.
As a workaround, you can compress or split the PDF below 20MB before uploading, or use the Files API directly to upload the large file and pass the file URI to your agent instead.
Activity
fix(plugins): Add 20MB file size validation to SaveFilesAsArtifactsPl…
fix(plugins): Add 20MB file size validation to SaveFilesAsArtifactsPl…
AakashSuresh2003 commentedon Dec 4, 2025
Hi @GWeale,
Could you please review my PR and provide any suggestions?
Add Files API integration for large files in SaveFilesAsArtifactsPlug…
AakashSuresh2003 commentedon Dec 5, 2025
Hi @GWeale,
As suggested, I’ve implemented an approach that uses file-size routing so the plugin now transparently supports files of all sizes without imposing a strict 20MB limit.
Summary of the Solution
I added automatic file-size detection and routing to ensure the correct upload path is used:
inline_data(fast path, no upload required)Additionally, the plugin now:
file_datareferences automatically.400 INVALID_ARGUMENTerror from reaching users.surajksharma07 commentedon Feb 3, 2026
@Smponias The plugin sends file data inline to the Gemini API which has a ~20MB limit — that's why your 50MB PDF hits a 400 INVALID_ARGUMENT.
There's no size validation in
save_files_as_artifacts_plugin.pycurrently.PR #3781 adds size-based routing (≤20MB inline, 20MB–2GB via Files API) but hasn't been merged yet.
As a workaround, you can compress or split the PDF below 20MB before uploading, or use the Files API directly to upload the large file and pass the file URI to your agent instead.
fix(plugins): Add 20MB file size validation to SaveFilesAsArtifactsPl…
Add Files API integration for large files in SaveFilesAsArtifactsPlug…
Add Files API integration for large files in SaveFilesAsArtifactsPlug…
surajksharma07 commentedon Mar 26, 2026
@DeanChensj Please have a look into it.
fix: add 20MB file size validation to SaveFilesAsArtifactsPlugin
fix: add 20MB file size validation to SaveFilesAsArtifactsPlugin