#23727: Fix Telegram channel resolution drift across announce + message send paths
channel: telegram
gateway
commands
agents
size: M
Cluster:
Network Error Handling Improvements
## Summary
- add a shared outbound channel resolver (`src/infra/outbound/channel-resolution.ts`) that:
- normalizes explicit channel inputs with deliverable-channel rules
- retries missing channel plugins by bootstrapping plugin registry from config (`applyPluginAutoEnable` + `loadOpenClawPlugins`)
- wire announce/send paths to use that shared resolver:
- `src/infra/outbound/targets.ts` (cron/subagent announce target resolution + heartbeat account/allowFrom checks)
- `src/infra/outbound/message.ts` (message/send + poll explicit channel handling)
- `src/gateway/server-methods/send.ts` (gateway `send`/`poll` channel plugin lookup)
This keeps channel resolution behavior consistent and recovers from empty/stale plugin registries in these outbound paths, preventing Telegram from being rejected as unsupported/unknown.
## Regression tests
- `src/infra/outbound/targets.channel-resolution.test.ts`
- reproduces and guards against `Unsupported channel: telegram` in announce target resolution
- `src/infra/outbound/message.test.ts`
- reproduces and guards against `Unknown channel: telegram` in message/send
## Verification
```bash
pnpm vitest src/infra/outbound/message.test.ts src/infra/outbound/targets.channel-resolution.test.ts src/infra/outbound/targets.test.ts src/gateway/server-methods/send.test.ts
pnpm lint -- src/infra/outbound/channel-resolution.ts src/infra/outbound/message.ts src/infra/outbound/targets.ts src/gateway/server-methods/send.ts src/infra/outbound/message.test.ts src/infra/outbound/targets.channel-resolution.test.ts
pnpm exec tsc --noEmit -p tsconfig.json --pretty false
```
Related: #21968 #21595 #13420 #14188
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR introduces a shared channel resolution module (`channel-resolution.ts`) that prevents Telegram and other plugins from being rejected as unsupported when the plugin registry is empty or stale. The fix applies consistently across announce/send paths by:
- Creating `resolveOutboundChannelPlugin()` that normalizes channel inputs and retries plugin lookup after bootstrapping the plugin registry from config
- Using a module-level `Set` to track bootstrap attempts per registry key, preventing infinite retry loops
- Replacing direct `getChannelPlugin()` calls in `targets.ts`, `message.ts`, and `send.ts` with the new shared resolver
The implementation includes regression tests that verify the bootstrap recovery mechanism works correctly for both announce target resolution and message send flows.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The refactoring follows established patterns, includes comprehensive regression tests for both affected code paths, uses proper deduplication to prevent infinite loops, and maintains backward compatibility by wrapping existing functions without changing their signatures
- No files require special attention
<sub>Last reviewed commit: 4381ffe</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#14795: fix: skip disabled channel plugins in cross-context messaging checks
by explainanalyze · 2026-02-12
80.5%
#17878: Refactor: share allowlist normalization
by iyoda · 2026-02-16
79.4%
#7141: fix(telegram): unify network error detection to prevent poll crashes
by hclsys · 2026-02-02
78.7%
#13881: fix: Address Greptile feedback - test isolation and channel resolution
by trevorgordon981 · 2026-02-11
78.6%
#17865: Refactor: centralize dm/group policy resolution
by iyoda · 2026-02-16
78.2%
#17337: fix(delivery): keep route fields paired to channel during context m...
by Glucksberg · 2026-02-15
78.2%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
77.6%
#17897: refactor: extract firstDefined utility from telegram/line/slack
by iyoda · 2026-02-16
77.2%
#23238: fix(telegram): account named "default" silently breaks inbound polling
by anillBhoi · 2026-02-22
77.0%
#23723: feat(message): improve send param ergonomics and actionable routing...
by SmithLabsLLC · 2026-02-22
76.9%