fix(tools): convert unsupported artifact MIME types to text in LoadArtifactsTool#1212
Conversation
|
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. |
|
@anFatum, can you please review this. |
2a4ffaa to
5141e56
Compare
|
@1wos thanks for the fix and the thorough tests! One small coverage gap surfaced by our internal analysis:
Could you add one test for an inline |
|
@kvmilos Thanks for the catch and review! Added a test covering the null MIME type case. |
|
@1wos Thanks! |
b808113 to
a60c246
Compare
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.