Skip to content

fix(gateway): prevent Telegram duplicate messages and tool-trace leakage (#36965 #37555) - #38732

Closed
ashishpatel26 wants to merge 1 commit into
NousResearch:mainfrom
ashishpatel26:fix/telegram-streaming-duplicate-context-leak-36965-37555
Closed

fix(gateway): prevent Telegram duplicate messages and tool-trace leakage (#36965 #37555)#38732
ashishpatel26 wants to merge 1 commit into
NousResearch:mainfrom
ashishpatel26:fix/telegram-streaming-duplicate-context-leak-36965-37555

Conversation

@ashishpatel26

Copy link
Copy Markdown
Contributor

Closes #36965. Closes #37555.

#36965: When cursor-strip finalize edit is rate-limited, _final_content_delivered stays False so run.py re-sends full response as duplicate. Fix: set flag when meaningful content was already in _last_sent_text.

#37555: _send_commentary had no guard; stale commentary items drained after delivery pushed tool-trace lines as visible messages. Fix: early-return False when delivery flags are set.

Adds 11 regression tests.

Closes NousResearch#36965. When cursor-strip finalize edit fails (rate-limited), the
prior streaming edits already delivered the content. Set
_final_content_delivered=True so run.py suppression check fires and no
duplicate sendMessage is triggered.

Closes NousResearch#37555. _send_commentary had no guard against post-delivery calls.
A stale commentary item drained after got_done could push a tool-trace
line (e.g. 'Using web_search...') as a visible chat message. Add early
return when _final_content_delivered or _final_response_sent is set.

Adds 11 regression tests.
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/telegram Telegram bot adapter labels Jun 9, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the regression analysis. This is an automated hermes-sweeper review; current main now implements a stronger Telegram-specific recovery path.

  • plugins/platforms/telegram/adapter.py:463-467 opts Telegram into immediate turn-final flood fallback and a durable fresh final message when a preview cannot be trusted.
  • gateway/stream_consumer.py:999-1009 routes an empty-tail final through _send_empty_fallback_final; that helper sends the final answer, cleans up the active preview, and records confirmed delivery (gateway/stream_consumer.py:1160-1226).
  • tests/gateway/test_telegram_final_delivery.py:100-140 covers the failed-final-edit/full-preview case, including fresh final delivery and preview cleanup.
  • The stale-commentary guard is also redundant on current main: _DONE stops queue draining at gateway/stream_consumer.py:587-595, and finalization returns before _send_commentary is reachable (gateway/stream_consumer.py:760-823).

The PR's proposed _last_sent_text-only suppression would be weaker because meaningful prior text can still be a partial response; current main explicitly preserves missing-tail delivery instead. The linked #36965 discussion was already closed as fixed, and #37555's separate session-collision issue was addressed independently.

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 sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

3 participants