Derive attachment content type from MIME type#150
Open
Adam-D-Lewis wants to merge 3 commits into
Open
Conversation
Attachments were hardcoded to the "document" AG-UI content type, so uploaded images (and audio/video) were mislabeled and never reached the model as the correct modality. Derive the discriminator from the file's MIME type instead, falling back to "document". Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jbouder
approved these changes
Jun 18, 2026
jbouder
left a comment
Contributor
There was a problem hiding this comment.
LGTM, just need to resolve the conflict
Resolve chatinput.tsx: keep main's refactor (error handling, file permission gating) and re-apply the MIME-derived attachment content type. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Derive attachment content type from MIME type
Repo:
nebari-chat-packBranch:
fix/derive-attachment-mime-typeBase:
mainCommit:
4efb6d2Summary
Attachments in the chat input were always tagged with the AG-UI
documentcontent type. This mislabels image/audio/video uploads, so a vision-capable
model never receives an uploaded image as an actual image. This PR derives the
AG-UI content discriminator from each file's MIME type instead.
Problem
In
frontend/src/chat/chatinput.tsx, when attached files are converted toFileInputContent, the discriminator was hardcoded:The downstream pipeline (Ravnar file handling → pydantic-ai AG-UI adapter) only
turns an
ImageInputContentinto an image part for the model. Adocument-typedimage is never converted to an image, so vision models can't see uploaded images
at all.
Change
Derive the discriminator from
file.type:image/*→imageaudio/*→audiovideo/*→videodocument(safe fallback)The valid discriminator literals (
image/audio/video/document) wereconfirmed against the
@ag-ui/coreFileInputContentdiscriminated union(
frontend/src/api/files.ts→ theagui.*InputContentSchemadefinitions).Files changed
frontend/src/chat/chatinput.tsxTesting
tsc --noEmitpasses.Notes
not user-visible: the file picker's
acceptattribute still restricts whichfiles can be selected. The companion change (
feat/capability-driven-uploads)makes the picker capability-driven and is stacked on top of this branch.