Skip to content

feat(telegram): add config option to disable link previews#8728

Closed
kovyrin wants to merge 4 commits into
NousResearch:mainfrom
kovyrin:feat/telegram-disable-link-previews
Closed

feat(telegram): add config option to disable link previews#8728
kovyrin wants to merge 4 commits into
NousResearch:mainfrom
kovyrin:feat/telegram-disable-link-previews

Conversation

@kovyrin

@kovyrin kovyrin commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds an opt-in Telegram gateway config option to disable link previews on outbound bot messages.

Problem solved:
Telegram links currently unfurl by default, which makes some Hermes bot replies noisy and visually heavy, especially alert-style messages where the link itself is useful but the preview card is not. This change makes it possible to keep links clickable while suppressing previews when the operator wants cleaner Telegram output.

Why this approach:

  • keeps the behavior configurable instead of hardcoding a Telegram policy
  • preserves current behavior by default
  • scopes the change cleanly to the Telegram adapter
  • supports both modern and legacy Telegram preview-suppression parameters
  • documents the setting in cli-config.yaml.example

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added Telegram adapter support for platforms.telegram.extra.disable_link_previews
  • Added helper logic to emit preview-suppression kwargs
  • Prefer link_preview_options(is_disabled=True) when available
  • Fall back to legacy disable_web_page_preview=True for compatibility
  • Wired preview suppression into Telegram outbound send_message paths in gateway/platforms/telegram.py
  • Hardened the preview helper to tolerate bare TelegramAdapter instances used in tests
  • Added regression coverage in tests/gateway/test_telegram_approval_buttons.py
  • Documented the config key in cli-config.yaml.example

How to Test

  1. Enable the option in config:
    platforms:
      telegram:
        extra:
          disable_link_previews: true
  2. Send a Telegram response containing a clickable markdown link and verify the link remains clickable but does not unfurl.
  3. Run targeted verification:
    source .venv/bin/activate
    python -m pytest tests/gateway/test_telegram_thread_fallback.py tests/gateway/test_telegram_approval_buttons.py -q

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: macOS

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Targeted test output:

18 passed in 3.63s

Notes:

  • pytest tests/ -q still reports unrelated failures in this checkout on macOS, so the full-suite checkbox is left unchecked.
  • clickable markdown links still work
  • preview cards are suppressed when the config option is enabled

@kovyrin kovyrin marked this pull request as ready for review April 13, 2026 02:51
@kovyrin-claw kovyrin-claw force-pushed the feat/telegram-disable-link-previews branch from 077d6dd to 57a686b Compare April 13, 2026 14:30
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #10610. Your commit(s) were cherry-picked onto current main with your authorship preserved in git log. Thanks @kovyrin!

@teknium1 teknium1 closed this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants