Skip to content

v0.4: Core Channel Reliability [PARTIAL]

Implementation Status

  • [x] Telegram, WhatsApp, Discord, Email, and Slack channel files exist.
  • [x] BaseChannel._handle_message() normalizes inbound text/media basics and enforces allow_from.
  • [x] ChannelManager supervises channel restarts and retries outbound sends.
  • [x] Tests cover reconnects, ported channel config, bridge token auth, CLI bridge login, and multimodal outbound basics.
  • [x] Shared channel capability flags exist for core channels.
  • [x] Normalized media envelope types exist and enrich legacy media paths.
  • [x] Shared delivery result/error contracts exist.
  • [x] Long-message splitting is implemented through channel capability limits.
  • [x] ChannelManager now normalizes send failures through DeliveryResult.
  • [x] Discord DM/thread session mapping metadata exists.
  • [ ] Channel-specific delivery error reporting still needs richer diagnostics.

Goal

Make daily channels solid before adding more channels.

User Outcome

WhatsApp, Telegram, and Discord should feel dependable enough for daily use: media works, commands work, errors are understandable, and reconnects do not silently lose state.

Scope

  • Harden WhatsApp media send/receive.
  • Add WhatsApp QR/login status command.
  • Keep owner-only admin command policy.
  • Improve bridge restart handling.
  • Improve outbound routing.
  • Make local-file and sandbox errors clear.
  • Bring Telegram media parity closer to WhatsApp.
  • Add Telegram group/DM policy and Markdown-safe responses.
  • Improve Discord attachment replies, reconnect behavior, and session mapping.
  • Add shared channel capability flags, message splitting, media envelopes, and delivery error reporting.

Module Targets

  • backend/agent/g_agent/channels/whatsapp.py
  • backend/agent/g_agent/channels/telegram.py
  • backend/agent/g_agent/channels/discord.py
  • backend/agent/g_agent/channels/base.py
  • backend/agent/bridge/
  • backend/agent/tests/test_whatsapp_channel.py
  • backend/agent/tests/test_telegram_channel.py
  • backend/agent/tests/test_discord_channel.py

Acceptance Criteria

  • [x] Each core channel has a text command path.
  • [x] Media receive creates usable path references for supported channels.
  • [x] Channel reconnects are supervised and retryable.
  • [x] Media send failures are classified through shared delivery error codes.
  • [x] Channel capability flags are available through channel instances.
  • [x] Long messages split safely per channel.

Tests

  • Command routing works for each core channel.
  • Media envelope normalization works.
  • Message splitting respects channel limits.
  • Delivery errors are surfaced.
  • Owner allowlist blocks unauthorized users.
  • Discord DM/thread mapping is stable.

References

  • Nanobot channel updates.
  • Hermes gateway release notes.

Agent Handoff

Current G-Agent State

  • BaseChannel._handle_message() already normalizes inbound messages and enforces allow_from.
  • ChannelManager already supervises channel restarts and retries outbound sends.
  • Telegram, WhatsApp, Discord, Email, and Slack channel files already exist.
  • channels/capabilities.py, channels/media.py, and channels/errors.py now provide the first shared channel contract slice.
  • Existing tests: test_channel_reconnect.py, test_ported_channels.py, test_bridge_token_auth.py, test_cli_bridge_login.py, test_multimodal_outbound.py, test_channel_contracts.py.
  • WhatsApp uses the Node bridge under backend/agent/bridge/; do not replace it without a separate bridge migration plan.

Reference Details To Inspect

  • nanobot-ref/nanobot/channels/telegram.py
  • nanobot-ref/nanobot/channels/discord.py
  • nanobot-ref/nanobot/channels/whatsapp.py
  • hermes-agent-ref/gateway/platforms/telegram.py
  • hermes-agent-ref/gateway/platforms/discord.py
  • hermes-agent-ref/gateway/platforms/whatsapp.py
  • Hermes tests around group gating, document handling, media download retry, formatting, reconnect, and unauthorized behavior.

Implementation Strategy

Add shared channel contracts first, then improve individual channels.

Recommended new shared types:

  • channels/capabilities.py: flags like supports_media_send, supports_media_receive, supports_buttons, supports_typing, max_text_chars, parse_mode.
  • channels/media.py: normalized media envelope with path/url, mime, filename, size, hash, channel metadata.
  • channels/errors.py: delivery error types.

Implementation Slices

  1. Add deeper WhatsApp media delivery diagnostics.
  2. Add richer Telegram group/topic policy tests.
  3. Preserve code blocks and links more intelligently across split boundaries.
  4. Improve media send/receive tests.
  5. Especially local file path and sandbox/allowed path errors.
  6. Telegram formatting safety.
  7. Add Markdown/HTML escape helper tests.
  8. Discord reconnect/thread mapping.
  9. Keep session key stable for DM/thread contexts.

Tests To Add Or Extend

  • test_channel_contracts.py
  • test_whatsapp_media_delivery.py
  • test_telegram_formatting.py
  • test_discord_session_mapping.py
  • Extend test_multimodal_outbound.py.

Guardrails

  • Do not add Feishu/Weixin/QQ/Microsoft Teams to core just because references have them.
  • Do not make channel reliability depend on Web UI.
  • Keep owner allowlist behavior strict.
  • Keep outbound retry idempotency from ChannelManager.

First PR Boundary

Channel capabilities + media envelope + tests. Then channel-specific hardening PRs for WhatsApp, Telegram, and Discord separately.