fix: use proxy for send_message_tool Telegram media uploads#20902
Closed
blackdeathdrow wants to merge 1 commit into
Closed
fix: use proxy for send_message_tool Telegram media uploads#20902blackdeathdrow wants to merge 1 commit into
blackdeathdrow wants to merge 1 commit into
Conversation
Collaborator
7fa29e9 to
69c8f3e
Compare
austinpickett
requested changes
May 19, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes tools/send_message_tool.py’s Telegram fallback sender so it can upload/send media successfully when a Telegram proxy is configured, aligning its behavior with the gateway adapter’s proxy handling.
Changes:
- Load the Hermes user
.envsoTELEGRAM_PROXYis available when the tool runs standalone. - In
_send_telegram(), resolveTELEGRAM_PROXYviaresolve_proxy_url(...)and configurepython-telegram-bot’sBotwith anHTTPXRequestthat includes the proxy.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+18
to
+21
| # Load .env file to make TELEGRAM_PROXY and other env vars available | ||
| try: | ||
| from dotenv import load_dotenv | ||
| load_dotenv(os.path.expanduser("~/.hermes/.env"), override=True) |
Comment on lines
+19
to
+23
| try: | ||
| from dotenv import load_dotenv | ||
| load_dotenv(os.path.expanduser("~/.hermes/.env"), override=True) | ||
| except ImportError: | ||
| pass # python-dotenv not required at module level |
Comment on lines
+714
to
+719
| # Create Bot with proxy support via HTTPXRequest | ||
| request_kwargs = {} | ||
| if proxy_url: | ||
| request_kwargs["proxy"] = proxy_url | ||
| bot_request = HTTPXRequest(**request_kwargs) | ||
| bot = Bot(token=token, request=bot_request) |
69c8f3e to
1e485e6
Compare
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?
send_message_tool fails to send photos/media via Telegram when a proxy is configured in ~/.hermes/.env. The gateway adapter works fine because it loads .env and uses HTTPXRequest(proxy=...), but the fallback _send_telegram() function creates a plain Bot(token=token) without any proxy configuration.
Root cause:
Solution:
Related Issue
Fixes # (no issue number yet — please create one if needed)
Type of Change
Changes Made
How to Test
result["success"]istrue.Checklist
Code
Documentation & Housekeeping
Screenshots / Logs
Before fix: Failed to send media ...jpg: Timed out (no proxy used)
After fix: Photo delivered successfully, Message ID received.