Skip to content

Fix duplicate Slack final replies after stream finalize failure#25258

Closed
guglielmofonda wants to merge 1 commit into
NousResearch:mainfrom
guglielmofonda:fix/slack-duplicate-final-send
Closed

Fix duplicate Slack final replies after stream finalize failure#25258
guglielmofonda wants to merge 1 commit into
NousResearch:mainfrom
guglielmofonda:fix/slack-duplicate-final-send

Conversation

@guglielmofonda

Copy link
Copy Markdown
Contributor

Summary

  • Prevent duplicate final Slack replies when a streamed message already shows the complete answer but the final chat.update/finalize edit fails transiently.
  • Add _visible_matches_final() to confirm the visible streamed body equals the cleaned final response before suppressing the normal gateway fallback send.
  • Add regression coverage for the finalize-failure path.

Fixes #25256

Test plan

  • python -m pytest tests/gateway/test_stream_consumer.py::TestFinalizeDuplicateSuppression -q
  • python -m pytest tests/gateway/test_stream_consumer.py tests/gateway/test_stream_consumer_draft.py -q

@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/slack Slack app adapter labels May 13, 2026
@teknium1

Copy link
Copy Markdown
Contributor

This appears to be implemented on current main by an earlier gateway streaming fix.

Automated hermes-sweeper review evidence:

  • bc42e62b171c622eab9dc9c2d9860e24feb1fe9f added final_content_delivered to track the case where final streamed content reached the user even if the cosmetic/finalize edit later failed.
  • gateway/stream_consumer.py:209 exposes final_content_delivered, and the stream finalization path marks it when final content is delivered.
  • gateway/run.py:15351 includes final_content_delivered in the confirmed-delivery check before setting already_sent, suppressing the normal gateway fallback send that caused the duplicate reply.
  • tests/gateway/test_duplicate_reply_suppression.py:469 covers the duplicate-suppression case and preserves fallback behavior when only intermediate text was visible.

The implementation uses a broader delivery-confirmation flag rather than the PR's proposed _visible_matches_final() helper, but it satisfies the linked #25256 acceptance criteria: no duplicate final body when streamed final content is already visible, while partial/intermediate streams still fall back.

@teknium1 teknium1 closed this Jun 12, 2026
@teknium1 teknium1 added the sweeper:implemented-on-main Sweeper: behavior already present on current main label Jun 12, 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/slack Slack app adapter sweeper:implemented-on-main Sweeper: behavior already present on current main type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slack streamed replies can duplicate after transient final edit failure

3 participants