fix(tools): surface dropped MEDIA attachments in send_message result#32880
Closed
konsisumer wants to merge 1 commit into
Closed
fix(tools): surface dropped MEDIA attachments in send_message result#32880konsisumer wants to merge 1 commit into
konsisumer wants to merge 1 commit into
Conversation
When a send_message MEDIA:<path> directive resolves outside the allowed media roots, the safety filter silently drops it and the text portion still sends, so the tool returned an unqualified success while the user received no attachment. Track the dropped count and append a warning to the successful result so the false-success no longer hides a missing attachment. Refs NousResearch#32644
Collaborator
|
Competing with #32054 and #31864 — all three surface rejected/dropped MEDIA paths in send_message results instead of silently dropping them. This PR is the most focused (send_message_tool.py only, 2 files). #32054 also covers base.py, run.py, scheduler.py, yuanbao, weixin. #31864 restructures filter_media_delivery_paths return type. All ref #32644. |
1 task
19 tasks
Contributor
Author
Contributor
Author
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.
What does this PR do?
Fixes the Telegram
MEDIA:<path>false-success in thesend_messagetool path. When a MEDIA directive resolves to a path outside the allowed media roots,filter_media_delivery_pathsdrops it (loggingSkipping unsafe MEDIA directive path outside allowed roots), but the text portion still sends — so the tool returned an unqualified{"success": true}while the user received no attachment. The model/user had no signal that the attachment was silently dropped.The fix records how many MEDIA paths the safety filter rejected and, when the send otherwise succeeds, appends a clear
warningsentry to the result. The text still delivers (so it isn't a hard error), but the result no longer masquerades as a successful attachment delivery, and it tells the operator how to fix it (move the file under a Hermes media cache or add its directory toHERMES_MEDIA_ALLOW_DIRS).Scope note: this addresses the false-success regression and adds regression coverage. The issue also asks for an operator-facing real-
sendVoice/sendAudiosmoke-test script and broader auditing of the gateway auto-delivery path — those are deferred to a follow-up, henceRefsrather thanFixesbelow.Related Issue
Refs #32644
Type of Change
Changes Made
tools/send_message_tool.py: in_handle_send, capture the requested MEDIA count before filtering, compute how many paths the safety filter dropped, and append a warning to a successful result when any were dropped.tests/tools/test_send_message_tool.py: addtest_dropped_media_surfaces_warning_not_clean_success(rejected archive path produces a warning) andtest_safe_media_send_has_no_dropped_warning(an allowlisted path still delivers with no false-positive warning).How to Test
[[audio_as_voice]]plus aMEDIA:<path>pointing outside the allowed media roots (e.g. an archived~/.hermes/voice-episodes/.../teaser.oggnot on the allowlist).success: truefor the text but now carries awarningsentry stating the attachment was blocked and not delivered.HERMES_MEDIA_ALLOW_DIRS(or move the file under a Hermes media cache) and resend; confirm the attachment is delivered and no dropped-media warning appears.pytest tests/tools/test_send_message_tool.py -k "media or dropped or safe_media" -q.Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/tools/test_send_message_tool.py -qand the relevant tests pass (24 passed)Documentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/Ascripts/check-windows-footguns.pyclean