Skip to content

test(gateway): align telegram DM topic metadata expectations with new direct_messages_topic_id key#27462

Closed
briandevans wants to merge 2 commits into
NousResearch:mainfrom
briandevans:fix/test-telegram-dm-topic-metadata-baseline
Closed

test(gateway): align telegram DM topic metadata expectations with new direct_messages_topic_id key#27462
briandevans wants to merge 2 commits into
NousResearch:mainfrom
briandevans:fix/test-telegram-dm-topic-metadata-baseline

Conversation

@briandevans

Copy link
Copy Markdown
Contributor

Summary

Two tests have been failing on every CI run on origin/main since 5338250da (fix(gateway): add direct_messages_topic_id for synthetic Telegram DM events) landed yesterday. The production change extended gateway/run.py::_thread_metadata_for_source to emit a new direct_messages_topic_id entry for non-General Telegram DM topic lanes, but two test expectations weren't updated alongside it. This PR aligns those snapshots — no production code is touched.

The bug

5338250da added six lines to gateway/run.py::_thread_metadata_for_source:

metadata["telegram_dm_topic_reply_fallback"] = True
# Telegram DM topic lanes need direct_messages_topic_id in metadata
# so synthetic/queued messages (goal continuations, status notices)
# route to the correct topic even when reply anchor is unavailable.
tid = str(thread_id)
if tid and tid not in {"", "1"}:
    metadata["direct_messages_topic_id"] = tid

For any Telegram DM MessageEvent with thread_id="20197", the helper now also emits "direct_messages_topic_id": "20197". Two tests use exactly that fixture and assert the metadata dict with a strict ==:

  • tests/gateway/test_telegram_thread_fallback.py::test_gateway_runner_busy_ack_replies_to_triggering_message_for_telegram_dm_topic
  • tests/gateway/test_voice_command.py::TestSendVoiceReply::test_auto_voice_reply_uses_thread_metadata_helper

Both fail on every CI run with:

Full diff:
  {
+     'direct_messages_topic_id': '20197',
      'telegram_dm_topic_reply_fallback': True,
      'telegram_reply_to_message_id': '463',
      'thread_id': '20197',
  }

These are baseline failures on clean origin/main (f36c89cd5) and show up red on every open PR.

The fix

Add "direct_messages_topic_id": "20197" to the expected metadata dict in each of the two failing assertions. Nothing else changes.

The other 12 occurrences of telegram_dm_topic_reply_fallback in test_telegram_thread_fallback.py test the Telegram adapter directly (without going through _thread_metadata_for_source) and continue to pass — only the two GatewayRunner-helper sites that call the production helper needed updating. Confirmed by running the full files: 194 passed, 21 skipped after the change vs 192 passed, 2 failed, 21 skipped before.

Test plan

  • Reproduced baseline failure on clean origin/main (f36c89cd5):
    FAILED tests/gateway/test_telegram_thread_fallback.py::test_gateway_runner_busy_ack_replies_to_triggering_message_for_telegram_dm_topic
    FAILED tests/gateway/test_voice_command.py::TestSendVoiceReply::test_auto_voice_reply_uses_thread_metadata_helper
    
  • Focused regression: both files combined — 194 passed, 21 skipped in 14.07s (was 192 passed, 2 failed, 21 skipped).
  • Regression guard: removing the new "direct_messages_topic_id": "20197" lines reproduces the original failure under the same harness; restoring them flips both tests back to PASSED.
  • No production code touched — gateway/run.py is untouched, so no risk of behavioral drift.

Related

  • Follow-up to 5338250da (fix(gateway): add direct_messages_topic_id for synthetic Telegram DM events) by @Timur00Kh

… direct_messages_topic_id key

Commit 5338250 ("fix(gateway): add direct_messages_topic_id for synthetic
Telegram DM events") extended _thread_metadata_for_source in gateway/run.py
to emit a new "direct_messages_topic_id" entry whenever a Telegram DM topic
lane has a non-General thread_id, but two test expectations weren't updated
in lockstep:

- tests/gateway/test_telegram_thread_fallback.py::
    test_gateway_runner_busy_ack_replies_to_triggering_message_for_telegram_dm_topic
- tests/gateway/test_voice_command.py::
    TestSendVoiceReply::test_auto_voice_reply_uses_thread_metadata_helper

Both exercise the busy-ack / auto-voice-reply paths against a synthetic
Telegram DM source with thread_id="20197", which now flows through the
new branch and triggers the extra key. They have been failing on every CI
run on origin/main since 5338250 landed.

Update each `==` metadata-dict assertion to include the new
`"direct_messages_topic_id": "20197"` entry alongside the existing keys.
No production behavior changes — only the test snapshots are aligned with
the new contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 17, 2026 14:13
@alt-glitch alt-glitch added type/test Test coverage or test infrastructure P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels May 17, 2026
…xpectation

The first commit on this branch updated test_telegram_thread_fallback.py and
test_voice_command.py to include `direct_messages_topic_id` in the expected
metadata dict (after gateway commit 5338250 started emitting this key for
synthetic Telegram DM events). A third test —
test_background_command.py::test_telegram_dm_topic_completion_preserves_reply_anchor_metadata
— exercises the same DM-topic completion path through `_run_background_task`
and was missed in the first sweep, so it kept failing on CI with:

  Left contains 1 more item:
  {'direct_messages_topic_id': '20197'}

Same one-line expected-dict fix as the other two files; brings the third test
file into line with current production behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@teknium1

Copy link
Copy Markdown
Contributor

Closing as already addressed — the test alignments your PR proposed are already passing on current main. The just-merged #28488 (salvage of #27937 route resumed DM topic sends via direct_messages_topic_id) brought base.py and telegram.py into alignment with these test expectations. Verified:

$ scripts/run_tests.sh tests/gateway/test_telegram_thread_fallback.py tests/gateway/test_background_command.py tests/gateway/test_voice_command.py -q
237 passed in 6.15s

Thanks for catching the inconsistency.

@teknium1 teknium1 closed this May 19, 2026
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 P2 Medium — degraded but workaround exists platform/telegram Telegram bot adapter type/test Test coverage or test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants