fix(simplex): classify inbound documents as MessageType.DOCUMENT - #35490
Closed
lambertian wants to merge 1 commit into
Closed
fix(simplex): classify inbound documents as MessageType.DOCUMENT#35490lambertian wants to merge 1 commit into
lambertian wants to merge 1 commit into
Conversation
Received documents (PDF/office/zip/etc.) arrived as MessageType.TEXT and were silently dropped by the gateway's DOCUMENT-gated attachment block. Classify non-image/non-audio attachments by a real MIME and promote application/* or text/* to MessageType.DOCUMENT, mirroring the existing image/voice handling. _doc_mime_for collapses any non-application/text guess to application/octet-stream so stray image/audio/video extensions don't re-route into the vision/STT pipelines. Relates to NousResearch#30150.
2 tasks
Author
|
Closing — superseded upstream. The inbound-document classification this PR adds (and the MIME-precision
Verified against current |
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.
Summary
Documents received over SimpleX (PDF / office / zip /
.txt/ etc.) currently arrive asMessageType.TEXTand are silently dropped. In_handle_new_chat_item, any non-image/non-audio attachment is taggedapplication/octet-streamand themsg_typeblock only promotesaudio/* -> VOICEandimage/* -> PHOTO, while the gateway's document-attachment block (gateway/run.py) forwards attachments only whenmessage_type == MessageType.DOCUMENT. So received documents reach the agent as a text note, not a file.This adds inbound document classification, mirroring the existing image/voice handling:
_doc_mime_for()maps common document extensions (pdf/txt/md/csv/json/docx/xlsx/pptx/zip/…) to real MIME types. For anything else it usesmimetypes.guess_type, but collapses any non-application/*/text/*guess toapplication/octet-streamso a strayimage/*oraudio/*guess (e.g..heic,.flac) cannot re-route the file into the vision/STT pipelines.application/octet-stream.msg_typebranch promotesapplication/*ortext/*->MessageType.DOCUMENT.Net effect: any attachment that isn't an allowlisted image/audio type is delivered to the agent as a document attachment instead of being dropped.
Tests (
tests/gateway/test_simplex_plugin.py)test_inbound_document_classified_as_document— a received.pdfdispatches aMessageEventtypedDOCUMENTwithapplication/pdfinmedia_types. Fails onmain(arrives asTEXT), passes with this change.test_inbound_unallowlisted_media_routes_to_document_not_photo_or_voice—.heic/.svg/.flac/.mp4classify asDOCUMENT, neverPHOTO/VOICE.test_doc_mime_for_maps_known_and_unknown_extensions— extension → MIME mapping, including the collapse and the unknown-extension fallback.Notes
fileStatusas a dict, the handler raises before this code runs; not touched here.