Skip to content

fix(gateway): don't upcast non-image attachments to image on PHOTO events - #50146

Closed
arminanton wants to merge 1 commit into
NousResearch:mainfrom
arminanton:feat/gateway-media-image-classification
Closed

fix(gateway): don't upcast non-image attachments to image on PHOTO events#50146
arminanton wants to merge 1 commit into
NousResearch:mainfrom
arminanton:feat/gateway-media-image-classification

Conversation

@arminanton

Copy link
Copy Markdown
Contributor

Summary

_build_media_placeholder and the image_paths collector in gateway/run.py
classified any attachment on a MessageType.PHOTO event as an image — even
when its MIME type was text/* or application/* (a document), or it was part
of a mixed album. That mislabels documents as images and routes them into the
vision/image-preprocessing pipeline.

Fix

Classify by MIME first; only fall back to the PHOTO message_type when MIME is
absent/ambiguous, and even then require an image extension or a single
attachment with empty/application/octet-stream MIME before treating it as an
image. Albums/documents are no longer upcast.

Tests

tests/gateway/test_media_image_classification.py (6 cases): image MIME,
text/application documents under PHOTO, mixed albums, single missing-MIME with
image extension, and audio/video classification. All pass.

Built on v0.17.0 (2bd1977d); net diff applies --3way onto the current base.

…ents

_build_media_placeholder and the image_paths collector classified any
attachment on a MessageType.PHOTO event as an image, even when its MIME type
was text/* or application/* (a document) or it was part of a mixed album.
That mislabels documents as images and routes them into the vision pipeline.

Classify by MIME first; only fall back to the PHOTO message_type when MIME is
absent/ambiguous, and even then require an image extension or a single
attachment with empty/octet-stream MIME before treating it as an image.

6 focused tests cover image MIME, text/application documents under PHOTO,
mixed albums, single missing-MIME image-ext, and audio/video.
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists labels Jun 21, 2026
arminanton added a commit to arminanton/hermes-agent that referenced this pull request Jun 21, 2026
…lines doc

Council demands:
- NousResearch#1 end-to-end replay: stacked 38/39 PRs on clean v0.17.0; the only 10 non-literal
  lines are my OWN intentional fixes (encoding-safe I/O NousResearch#50033/NousResearch#50064, public-value
  test NousResearch#50078) — replay tree is a SUPERSET of overlay intent, 0 lost.
- NousResearch#3 independent spot-check via PLAIN git apply (not my scripts): NousResearch#48024/NousResearch#50146/NousResearch#50046
  all apply clean exit 0.
- NousResearch#4 the 3 deleted test_model_metadata lines documented findably here + in
  complete_diff_coverage.md (overlay's private-900K deletion, public PR keeps 272K).
arminanton added a commit to arminanton/hermes-agent that referenced this pull request Jun 22, 2026
…rdict

Each open PR replayed onto v0.17.0 + tests run. Verdict per PR (not just coverage):
34 clean apply + tests/code-only; 6 conflict PRs with verified v0.17.0 patches; the
5 with failures root-caused (NousResearch#50066/NousResearch#50086 pre-existing v0.17.0 flake reproduced on
clean v0.17.0; NousResearch#50031/NousResearch#50032/NousResearch#50078 declared stack-deps that pass on full overlay).
NousResearch#50146 + NousResearch#50155 (secondary co-owners, previously only co-listed) now individually
verified: CLEAN apply + 6 passed each. 0 PRs left needing review.
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for isolating the mixed-attachment failure. This automated hermes-sweeper review finds that current main already implements the requested behavior, so this PR is now redundant.

  • gateway/run.py:2009-2021 added _event_media_is_image, which trusts each attachment's MIME and falls back to PHOTO only when that MIME is absent.
  • Both paths named in this PR use that helper: _build_media_placeholder at gateway/run.py:2051 and the inbound image_paths collector at gateway/run.py:10412. Non-image attachments continue to the document-context path at gateway/run.py:10531-10571.
  • tests/gateway/test_mixed_attachment_routing.py:42-46 and :71-76 already cover a PHOTO event containing an image and a text document.
  • The implementation landed in 505bc27d8d911465ae1e6e63e9329455f8213ecb and is included in v2026.7.1.

Closing as implemented on main.

@teknium1 teknium1 closed this Jul 14, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants