Skip to content

fix(gateway): keep Discord docs out of photo vision routing - #26409

Closed
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:hermes/fix-25935-discord-mixed-attachments
Closed

fix(gateway): keep Discord docs out of photo vision routing#26409
LeonSGP43 wants to merge 1 commit into
NousResearch:mainfrom
LeonSGP43:hermes/fix-25935-discord-mixed-attachments

Conversation

@LeonSGP43

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the mixed-attachment half of #25935. When a Discord message contains both images and documents, Hermes currently treats every attachment as an image if the message-level type is PHOTO. That causes non-image files like .md to be forwarded into the vision image path and can trigger provider-side Could not process image 400s.

This patch narrows the fallback: Hermes now trusts each attachment's own MIME type first, and only falls back to the message-level PHOTO classification when that attachment has no per-file MIME metadata.

Related Issue

Addresses #25935

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Update gateway/run.py to classify inbound media per attachment, so document attachments on Discord photo messages no longer enter the image routing / vision path.
  • Reuse the same per-attachment classification for busy-session media placeholders, so queued mixed attachments keep image/file distinctions.
  • Add regressions in tests/gateway/test_native_image_buffer_isolation.py covering mixed image+document photo messages.

How to Test

  1. Run python3 -m pytest -o addopts='' tests/gateway/test_native_image_buffer_isolation.py.
  2. Verify a MessageType.PHOTO event with media_types=["image/png", "text/markdown"] only buffers the image path for native vision delivery.
  3. Verify the busy placeholder renders the image attachment as an image and the .md attachment as a file, instead of marking both as images.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS 15.x

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — N/A

Screenshots / Logs

  • python3 -m pytest -o addopts='' tests/gateway/test_native_image_buffer_isolation.py4 passed in 0.35s
  • python3 -m py_compile gateway/run.py tests/gateway/test_native_image_buffer_isolation.py
  • git diff --check
  • Broader tests/gateway/test_discord_document_handling.py is red in this environment before/after the patch because current Discord attachment tests hit existing SSRF URL blocking against https://cdn.discordapp.com/attachments/fake/file; not caused by this change.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/discord Discord bot adapter tool/vision Vision analysis and image generation P2 Medium — degraded but workaround exists labels May 15, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #25936, which also fixes #25935 (per-attachment MIME classification to prevent docs from entering image routing). #25936 additionally adds image format transcoding.

@teknium1

Copy link
Copy Markdown
Contributor

Merged via PR #53923 (commit 505bc27d) — #53923

Salvaged onto current main with both bugs fixed (mixed-attachment per-attachment routing + uncommon-format transcode), plus the document-context-note path widened so a doc mixed into a photo message reaches the agent as a readable file. Your work was combined with two other independent fixes for this issue and all three contributors are credited in the PR; @shashwatgokhe's authorship is preserved on the merge commit. Thanks for the fix.

@teknium1 teknium1 closed this Jun 28, 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 platform/discord Discord bot adapter tool/vision Vision analysis and image generation type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants