feat: add proxy support for Discord, Slack, and SMS platform senders#2208
Closed
jhbarnett wants to merge 2 commits into
Closed
feat: add proxy support for Discord, Slack, and SMS platform senders#2208jhbarnett wants to merge 2 commits into
jhbarnett wants to merge 2 commits into
Conversation
Read DISCORD_PROXY or HTTPS_PROXY env var and pass to discord.py's Bot constructor and image download session. This routes both WebSocket gateway and REST API traffic through an HTTP proxy (e.g. Squid), enabling network-level egress control. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The cron scheduler delivers via _send_discord/_send_slack/_send_sms in send_message_tool.py, which create bare aiohttp sessions that ignore HTTPS_PROXY. This causes DNS resolution failures when running behind a forward proxy (e.g. Squid) where direct outbound is blocked. Pass proxy= to each aiohttp request, matching the pattern already used in gateway/platforms/discord.py for the bot connection and image downloads. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35f4743 to
9d5ca9a
Compare
Author
🐢 CodeTrotter WalkthroughAn AI-powered review of this PR is ready on CodeTrotter:
|
1 task
teknium1
added a commit
that referenced
this pull request
Apr 9, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR #6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue #6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR #2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
teknium1
added a commit
that referenced
this pull request
Apr 9, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR #6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue #6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR #2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
Contributor
|
Superseded by PR #6814 which includes your send_message_tool.py proxy coverage pattern (Discord REST, Slack, SMS) along with unified resolver and SOCKS support. Thanks for the multi-platform proxy work @jhbarnett! |
Tommyeds
pushed a commit
to Tommyeds/hermes-agent
that referenced
this pull request
Apr 12, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 28, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
ulasbilgen
pushed a commit
to ulasbilgen/hermes-adhd-agent
that referenced
this pull request
May 1, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
olympus-terminal
pushed a commit
to olympus-terminal/hermes-agent
that referenced
this pull request
May 16, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
Egavasyug
pushed a commit
to Egavasyug/hermes-agent
that referenced
this pull request
Jun 10, 2026
… proxy coverage Follow-up improvements on top of the shared resolver from PR NousResearch#6562: - Add platform_env_var parameter to resolve_proxy_url() so DISCORD_PROXY takes priority over generic HTTPS_PROXY/ALL_PROXY env vars - Add SOCKS proxy support via aiohttp_socks.ProxyConnector with rdns=True (critical for GFW/Shadowrocket/Clash users — issue NousResearch#6649) - proxy_kwargs_for_bot() returns connector= for SOCKS, proxy= for HTTP - proxy_kwargs_for_aiohttp() returns split (session_kw, request_kw) for standalone aiohttp sessions - Add proxy support to send_message_tool.py (Discord REST, Slack, SMS) for cron job delivery behind proxies (from PR NousResearch#2208) - Add proxy support to Discord image/document downloads - Fix duplicate import sys in base.py
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.
Summary
Add HTTP proxy support for all aiohttp-based platform connections: Discord gateway (WebSocket), Discord REST API, Slack Web API, and Twilio SMS API.
DISCORD_PROXYenv var (withHTTPS_PROXYfallback) for Discord connectionsHTTPS_PROXYfor Slack and SMS (Twilio) connectionsproxy=None)Motivation
When running hermes-agent behind a forward proxy (e.g. Squid) for egress control, aiohttp-based platform clients bypass the proxy because
aiohttp.ClientSessiondoes not readHTTPS_PROXYby default. This causes DNS resolution failures and connection timeouts for cron job delivery and direct message sending.The Anthropic/GitHub/OpenRouter SDK clients respect
HTTPS_PROXY, but Discord, Slack, and SMS connections go direct.Changes
gateway/platforms/discord.py— two patch points:commands.Bot(proxy=...)proxy=tosession.get()insend_image()tools/send_message_tool.py— three patch points (used by cron delivery and thesend_messagetool):_send_discord(): passproxy=tosession.post()for Discord REST API calls_send_slack(): passproxy=tosession.post()for Slack Web API calls_send_sms(): passproxy=tosession.post()for Twilio REST API callsNo dependency changes — discord.py >= 2.0 and aiohttp both support the
proxykwarg natively.Platforms not affected
python-telegram-botwhich respects env varshttpxwhich respects env varssmtplib(not HTTP)Test plan
internal: true)discord.comCONNECT tunnels visibleDISCORD_PROXY/HTTPS_PROXYset, behavior is unchanged (proxy=None)🤖 Generated with Claude Code