fix(gateway): tighten MEDIA extraction regex + silent skip on file-not-found (#28249)#28350
Merged
Conversation
…t-found Three related fixes for the MEDIA:<path> extraction pipeline that caused 'file not found' noise in platform channels: 1. run.py — tighten tool-result MEDIA regex from \S+ (any non- whitespace) to require a path pattern with known extensions. Prevents LLM-generated placeholder paths like 'MEDIA:/path/to/example.mp4' from being captured as real media. 2. base.py — remove the |\S+ fallback in extract_media() that catches anything non-whitespace as a potential MEDIA path. This was the primary cause of false positives — strings like '' in tool output were captured as MEDIA: paths. 3. mattermost.py — replace the file-not-found error message sent to the channel with a silent logger.warning() skip. When a path extracted by MEDIA doesn't exist on disk, the channel no longer gets a noisy '(file not found: ...)' message. Impact: eliminates the persistent 'file not found' spam in Mattermost channels caused by over-broad MEDIA regex patterns matching non-path text in tool output.
Contributor
🔎 Lint report:
|
19 tasks
This was referenced May 29, 2026
briandevans
added a commit
to briandevans/hermes-agent
that referenced
this pull request
May 29, 2026
…o main room `_send_local_file` previously surfaced `(file not found: ...)` via `self.send(room_id, ...)` without propagating `metadata` — which carries `thread_id` for threaded sends. The error message therefore landed in the main room even when the original MEDIA send was thread-targeted, on top of being a confusing user-visible reply for a problem the agent has already moved past. Mirror the mattermost adapter pattern landed in NousResearch#28350: log a warning and return `SendResult(success=True, message_id=None)`. The agent's turn is done by the time the missing file is detected, so treating it as a silent skip avoids both the wrong-room leak and pointless delivery retries. Fixes NousResearch#32503
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.
Salvage of #28249 by @colin-chang.
What: Two issues in MEDIA delivery:
gateway/platforms/base.pyand the tool-result MEDIA scanner ingateway/run.pymatched overly broad paths, sometimes capturing trailing junk._send_local_file()surfaced(file not found: ...)as a user-visible reply when the file was missing. The agent had already moved on; the gateway should just log and skip.How:
|\\S+clause that produced false-positive captures).logger.warning+ silent skip (returnsSendResult(success=True)).gateway/run.pyso it's not rebuilt every iteration.Original PR: #28249