Skip to content

fix(gateway): deliver MEDIA: files after streaming responses#2382

Merged
teknium1 merged 1 commit intomainfrom
hermes/hermes-40b195db
Mar 21, 2026
Merged

fix(gateway): deliver MEDIA: files after streaming responses#2382
teknium1 merged 1 commit intomainfrom
hermes/hermes-40b195db

Conversation

@teknium1
Copy link
Copy Markdown
Contributor

When streaming is enabled, text chunks go directly to the user including raw MEDIA:/path/to/file tags. The normal post-processing in _process_message_background is skipped when already_sent=True, so MEDIA: files were never extracted or delivered.

Users on Telegram (and other platforms) with streaming enabled saw literal MEDIA:/home/user/.hermes/... text but never received the actual file attachment.

Fix: After streaming completes, call _deliver_media_from_response() to extract MEDIA: tags and local file paths, then deliver them via the platform adapter's native send methods (send_document, send_image_file, send_video, send_voice).

The raw MEDIA: tag text still appears in the streamed output (can't un-send already-streamed chunks), but the actual files now get delivered as separate attachments afterward.

1286 gateway tests pass.

When streaming is enabled, text chunks are sent to the user in
real-time including raw MEDIA: tags. The normal post-processing in
_process_message_background is skipped when already_sent=True, so
MEDIA: files were never extracted or delivered — the user just saw
the raw MEDIA:/path/to/file text.

Fix: after streaming completes, extract MEDIA: tags and local file
paths from the response and deliver them via the platform adapter.
The text is already sent (with the raw tag visible in the stream),
but the actual files now get delivered as attachments.
@teknium1 teknium1 merged commit f7f75de into main Mar 21, 2026
1 check passed
teknium1 added a commit that referenced this pull request Mar 22, 2026
Two fixes:

1. CLI /stop command crashed with 'cannot import name get_registry' —
   the code imported a non-existent function. Fixed to use the actual
   process_registry singleton and list_sessions() method.
   (Reported in #2458 by haiyuzhong1980)

2. Streaming media delivery used undefined 'adapter' variable —
   our PR #2382 called _deliver_media_from_response(adapter=adapter)
   but 'adapter' wasn't guaranteed to be defined in that scope.
   Fixed to resolve via self.adapters.get(source.platform).
   (Reported in #2424 by 42-evey)
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
Two fixes:

1. CLI /stop command crashed with 'cannot import name get_registry' —
   the code imported a non-existent function. Fixed to use the actual
   process_registry singleton and list_sessions() method.
   (Reported in NousResearch#2458 by haiyuzhong1980)

2. Streaming media delivery used undefined 'adapter' variable —
   our PR NousResearch#2382 called _deliver_media_from_response(adapter=adapter)
   but 'adapter' wasn't guaranteed to be defined in that scope.
   Fixed to resolve via self.adapters.get(source.platform).
   (Reported in NousResearch#2424 by 42-evey)
aashizpoudel pushed a commit to aashizpoudel/hermes-agent that referenced this pull request Mar 30, 2026
Two fixes:

1. CLI /stop command crashed with 'cannot import name get_registry' —
   the code imported a non-existent function. Fixed to use the actual
   process_registry singleton and list_sessions() method.
   (Reported in NousResearch#2458 by haiyuzhong1980)

2. Streaming media delivery used undefined 'adapter' variable —
   our PR NousResearch#2382 called _deliver_media_from_response(adapter=adapter)
   but 'adapter' wasn't guaranteed to be defined in that scope.
   Fixed to resolve via self.adapters.get(source.platform).
   (Reported in NousResearch#2424 by 42-evey)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant