fix(tools): convert unsupported artifact MIME types to text in LoadArtifactsTool#1212
Open
1wos wants to merge 1 commit into
Open
fix(tools): convert unsupported artifact MIME types to text in LoadArtifactsTool#12121wos wants to merge 1 commit into
1wos wants to merge 1 commit into
Conversation
Contributor
|
Hi @1wos, Thank you for your contribution! We appreciate you taking the time to submit this pull request. Currently this PR is under review by our team, we will keep you posted if any additional information is required. thank you. |
Contributor
|
@anFatum, can you please review this. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Link to Issue or Description of Change
Problem:
LoadArtifactsToolappends loaded artifact parts directly into the next model request. When the inline MIME is not accepted by Gemini, the follow-up request fails withUnsupported MIME Typeinstead of continuing with usable context. Same class of issue as adk-python #4028 (fixed by commitfdc98d5c).Solution:
Before appending a loaded artifact, classify its MIME type and fall back to a model-safe part:
image/*,audio/*,video/*,application/pdftext/*,application/csv,application/json,application/xmlMIME normalization strips the
;charset=...parameter, soapplication/csv; charset=utf-8is handled the same asapplication/csv.Testing Plan
Unit Tests:
Added five cases covering the fallback paths:
processLlmRequest_unsupportedTextLikeMime_convertsToTextprocessLlmRequest_supportedMime_keepsInlineDataprocessLlmRequest_unsupportedBinaryMime_convertsToPlaceholderprocessLlmRequest_unsupportedMimeWithoutInlineData_convertsToNoDataPlaceholderprocessLlmRequest_emptyMime_defaultsToOctetStream12/12 pass.
Manual End-to-End (E2E) Tests:
Adapted
contrib/samples/helloworldlocally (not part of this PR) as a temporary driver: saved aweather.csvartifact withapplication/csvinline MIME and asked the agent to describe it against the live Gemini API. The agent loaded the artifact, the fallback converted the inline csv to a text part, and the model produced an accurate description:Without the fallback, this request fails with
Unsupported MIME Typebefore the model can respond.Checklist
Additional context
Ports the behavior introduced in adk-python by commit
fdc98d5c(Close #4028). Follows the "Alignment with adk-python" section of CONTRIBUTING.md.