Bug
When multiple /queue items are chained in a single session via the FIFO queue mechanism, only the last queue item gets its MEDIA files delivered. All preceding items have their MEDIA:/path/to/file tags rendered as raw text — the files are generated but never uploaded to the messaging platform.
Root Cause
Two code paths are responsible:
1. Normal path (works correctly) — gateway/platforms/base.py line 2724:
response = await self._message_handler(event)
# ...
if response:
media_files, response = self.extract_media(response) # ← MEDIA extracted before send
await self.send(chat_id, cleaned_text)
Every _handle_message return goes through extract_media() before delivery.
2. Queue follow-up path (broken) — gateway/run.py lines 13079-13098:
# First queue item complete, second in line → deliver first response
first_response = result.get("final_response", "")
if first_response and not _already_streamed:
await adapter.send(source.chat_id, first_response, ...) # ← RAW text, no extract_media!
This directly calls adapter.send() with the raw final_response — including MEDIA:/path tags — bypassing extract_media() entirely. The files exist on disk but never get uploaded.
The queue drain loop (added for FIFO /queue semantics) handles its own "deliver previous response → run next queue item" pipeline, but never calls extract_media() or _deliver_media_from_response() for non-last items.
The streaming path at line 6244 already calls _deliver_media_from_response() correctly — this same treatment is missing from the queue drain path.
Steps to Reproduce
- In a single session, send two
/queue commands that each produce files:
/queue Generate a PDF report → deliver with MEDIA:/tmp/report1.pdf
/queue Generate another PDF → deliver with MEDIA:/tmp/report2.pdf
- Wait for both to complete
- Expected: Both PDFs delivered natively
- Actual: Only
report2.pdf is delivered (or streamed). report1.pdf shows as raw MEDIA:/tmp/report1.pdf text.
Affected Code
gateway/run.py ~13079-13098 — queue follow-up response delivery, missing extract_media() call
gateway/run.py ~6244-6262 — streaming path already has _deliver_media_from_response() correctly (reference)
gateway/platforms/base.py ~2724 — normal path correctly calls extract_media() (reference)
Suggested Fix
Insert extract_media() call before adapter.send() in the queue follow-up path (~line 13086):
if first_response and not _already_streamed:
# Extract and deliver MEDIA files before sending the text
media_files, first_response = adapter.extract_media(first_response)
await adapter.send(source.chat_id, first_response, ...)
And deliver the extracted media files via the adapter's native media upload path.
Workaround
- Send queue items one at a time (don't chain)
- Use cronjob for file-generating tasks instead of
/queue
- Bundle all files into the last queue item
Bug
When multiple
/queueitems are chained in a single session via the FIFO queue mechanism, only the last queue item gets its MEDIA files delivered. All preceding items have theirMEDIA:/path/to/filetags rendered as raw text — the files are generated but never uploaded to the messaging platform.Root Cause
Two code paths are responsible:
1. Normal path (works correctly) —
gateway/platforms/base.pyline 2724:Every
_handle_messagereturn goes throughextract_media()before delivery.2. Queue follow-up path (broken) —
gateway/run.pylines 13079-13098:This directly calls
adapter.send()with the rawfinal_response— includingMEDIA:/pathtags — bypassingextract_media()entirely. The files exist on disk but never get uploaded.The queue drain loop (added for FIFO
/queuesemantics) handles its own "deliver previous response → run next queue item" pipeline, but never callsextract_media()or_deliver_media_from_response()for non-last items.The streaming path at line 6244 already calls
_deliver_media_from_response()correctly — this same treatment is missing from the queue drain path.Steps to Reproduce
/queuecommands that each produce files:report2.pdfis delivered (or streamed).report1.pdfshows as rawMEDIA:/tmp/report1.pdftext.Affected Code
gateway/run.py~13079-13098 — queue follow-up response delivery, missingextract_media()callgateway/run.py~6244-6262 — streaming path already has_deliver_media_from_response()correctly (reference)gateway/platforms/base.py~2724 — normal path correctly callsextract_media()(reference)Suggested Fix
Insert
extract_media()call beforeadapter.send()in the queue follow-up path (~line 13086):And deliver the extracted media files via the adapter's native media upload path.
Workaround
/queue