Skip to content

fix(telegram): preserve link preview disable on edits - #61022

Open
samrusani wants to merge 1 commit into
NousResearch:mainfrom
samrusani:fix/61018-telegram-edit-link-previews
Open

fix(telegram): preserve link preview disable on edits#61022
samrusani wants to merge 1 commit into
NousResearch:mainfrom
samrusani:fix/61018-telegram-edit-link-previews

Conversation

@samrusani

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes the Telegram legacy edit path so platforms.telegram.extra.disable_link_previews: true is honored when assistant output is updated via edit_message_text.

The initial send path already passed link_preview_options, but streaming edits, final MarkdownV2 edits, plain-text fallback edits, retry edits, and overflow first-chunk edits did not. That let Telegram create URL preview cards during response edits even though the user had disabled link previews.

Related Issue

Fixes #61018

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

  • plugins/platforms/telegram/adapter.py: pass self._link_preview_kwargs() through all legacy Telegram edit_message_text calls used by streaming edits, final MarkdownV2 edits, fallback edits, retry edits, and overflow first-chunk edits.
  • tests/gateway/test_telegram_format.py: add regressions proving disable_link_previews is preserved for non-final edits, final Markdown/fallback edits, and overflow first-chunk edits.

How to Test

  1. ./.venv/bin/pytest tests/gateway/test_telegram_format.py::TestEditMessageStreamingSafety -q
  2. ./.venv/bin/pytest tests/gateway/test_telegram_format.py -q
  3. ./.venv/bin/python -m py_compile plugins/platforms/telegram/adapter.py tests/gateway/test_telegram_format.py
  4. git diff --check

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 with repo .venv / Python 3.11-compatible test environment

Documentation & Housekeeping

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

Screenshots / Logs

Focused validation passed locally:

  • ./.venv/bin/pytest tests/gateway/test_telegram_format.py::TestEditMessageStreamingSafety -q — 12 passed
  • ./.venv/bin/pytest tests/gateway/test_telegram_format.py -q — 112 passed
  • ./.venv/bin/python -m py_compile plugins/platforms/telegram/adapter.py tests/gateway/test_telegram_format.py
  • git diff --check

@alt-glitch alt-glitch added type/bug Something isn't working platform/telegram Telegram bot adapter comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 8, 2026
@teknium1 teknium1 added the sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform label Jul 10, 2026
@samrusani
samrusani marked this pull request as ready for review July 11, 2026 15:36
@samrusani
samrusani force-pushed the fix/61018-telegram-edit-link-previews branch from c881918 to ce02187 Compare August 3, 2026 07:15
@samrusani

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (d1afa1605) and force-pushed head ce021875c.

The only conflict was the reorganized TestEditMessageStreamingSafety section in tests/gateway/test_telegram_format.py. The resolution keeps current main's overflow-preview/flood-control regressions and relocates only this PR's three link-preview checks; the production adapter change continues to cover streaming edits, MarkdownV2 and plain fallback edits, retry edits, and overflow first-chunk edits.

Validation on the rebased head:

  • scripts/run_tests.sh tests/gateway/test_telegram_format.py -k 'non_final_edit_disables_link_preview_when_configured or final_edit_disables_link_preview_on_markdown_and_plain_fallback or message_too_long_first_chunk_edit_disables_link_preview' -q — 3 passed
  • scripts/run_tests.sh tests/gateway/test_telegram_format.py -q — 45 passed
  • focused Ruff — passed
  • Python compilation — passed
  • git diff --check origin/main...HEAD — passed

GitHub now reports the PR mergeable; CI is running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P3 Low — cosmetic, nice to have platform/telegram Telegram bot adapter sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Telegram: disable_link_previews not applied in edit_message legacy MarkdownV2 path

3 participants