Bug: Telegram plugin setGlobalDispatcher breaks Anthropic API calls (HTTP 403)
Version
- OpenClaw: 2026.2.26 (bc50708)
- Node.js: v22.22.0
- OS: macOS (Apple Silicon)
Summary
When the Telegram plugin starts with a valid botToken, it calls setGlobalDispatcher() from undici, replacing the global HTTP dispatcher. This causes all subsequent HTTP requests — including Anthropic API calls — to fail with HTTP 403 Forbidden.
Steps to Reproduce
- Configure Telegram channel with
botToken and proxy:
{
"channels": {
"telegram": {
"enabled": true,
"botToken": "<valid-token>",
"dmPolicy": "pairing",
"proxy": "http://127.0.0.1:29758"
}
}
}
- Restart gateway:
openclaw gateway --force
- Agent embedded runs fail with:
error=HTTP 403 forbidden: Request not allowed
Root Cause
In dist/send-DslMV0Oj.js (and other send-*.js files), the function applyTelegramNetworkWorkarounds() calls:
setGlobalDispatcher(new Agent({ connect: {
autoSelectFamily: autoSelectDecision.value,
autoSelectFamilyAttemptTimeout: 300
} }));
This replaces the global Node.js undici dispatcher, affecting all HTTP clients in the process — not just Telegram. The Anthropic SDK (and any other HTTP client) then uses this modified dispatcher, which causes 403 errors.
Workaround
Patch all send-*.js files to disable the global dispatcher override:
# Find and patch all affected files
for f in /opt/homebrew/lib/node_modules/openclaw/dist/send-*.js \
/opt/homebrew/lib/node_modules/openclaw/dist/plugin-sdk/send-*.js; do
if grep -q "setGlobalDispatcher" "$f"; then
cp "$f" "$f.bak"
python3 -c "
with open('$f', 'r') as fh:
c = fh.read()
old = 'if (autoSelectDecision.value !== null && autoSelectDecision.value !== appliedGlobalDispatcherAutoSelectFamily) try {'
new = 'if (false && autoSelectDecision.value !== null && autoSelectDecision.value !== appliedGlobalDispatcherAutoSelectFamily) try {'
c = c.replace(old, new)
with open('$f', 'w') as fh:
fh.write(c)
print(f'patched: $f')
"
fi
done
Suggested Fix
Instead of calling setGlobalDispatcher(), create a scoped undici Agent and pass it only to the Telegram bot's fetch/HTTP client. This avoids polluting the global dispatcher that other subsystems (Anthropic SDK, etc.) depend on.
Additional Context
- This issue did not exist in v2026.2.22
- Without
botToken, the Telegram plugin doesn't fully start, so the bug doesn't trigger
- The proxy configuration itself is not the issue — even without
proxy, adding botToken alone triggers the 403
- Affected files:
send-DslMV0Oj.js, send-7Nj0TwhR.js, send-CpkY_YZv.js, send-DWL38WYk.js, plugin-sdk/send-DH8cfz_-.js
Bug: Telegram plugin
setGlobalDispatcherbreaks Anthropic API calls (HTTP 403)Version
Summary
When the Telegram plugin starts with a valid
botToken, it callssetGlobalDispatcher()fromundici, replacing the global HTTP dispatcher. This causes all subsequent HTTP requests — including Anthropic API calls — to fail with HTTP 403 Forbidden.Steps to Reproduce
botTokenandproxy:{ "channels": { "telegram": { "enabled": true, "botToken": "<valid-token>", "dmPolicy": "pairing", "proxy": "http://127.0.0.1:29758" } } }openclaw gateway --forceerror=HTTP 403 forbidden: Request not allowedRoot Cause
In
dist/send-DslMV0Oj.js(and othersend-*.jsfiles), the functionapplyTelegramNetworkWorkarounds()calls:This replaces the global Node.js undici dispatcher, affecting all HTTP clients in the process — not just Telegram. The Anthropic SDK (and any other HTTP client) then uses this modified dispatcher, which causes 403 errors.
Workaround
Patch all
send-*.jsfiles to disable the global dispatcher override:Suggested Fix
Instead of calling
setGlobalDispatcher(), create a scoped undiciAgentand pass it only to the Telegram bot's fetch/HTTP client. This avoids polluting the global dispatcher that other subsystems (Anthropic SDK, etc.) depend on.Additional Context
botToken, the Telegram plugin doesn't fully start, so the bug doesn't triggerproxy, addingbotTokenalone triggers the 403send-DslMV0Oj.js,send-7Nj0TwhR.js,send-CpkY_YZv.js,send-DWL38WYk.js,plugin-sdk/send-DH8cfz_-.js