Skip to content

fix(matrix): remove forced buffer_only streaming to enable progressive m.replace edits - #58770

Closed
Kewe63 wants to merge 1 commit into
NousResearch:mainfrom
Kewe63:fix/58728-matrix-streaming-buffer-only
Closed

fix(matrix): remove forced buffer_only streaming to enable progressive m.replace edits#58770
Kewe63 wants to merge 1 commit into
NousResearch:mainfrom
Kewe63:fix/58728-matrix-streaming-buffer-only

Conversation

@Kewe63

@Kewe63 Kewe63 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Matrix gateway was sending only final/split m.room.message events — zero m.replace (m.relates_to.rel_type == "m.replace") edits, despite streaming being enabled both globally and for the Matrix platform. Long answers arrived as monolithic messages instead of progressive live updates (#58728).

Control tests confirmed the individual pieces worked:

  • Direct Matrix API m.replace edits work in the test room.
  • GatewayStreamConsumer with buffer_only=False produces edits with a fake adapter.

Root Cause

gateway/run.py forced buffer_only = True exclusively for Matrix at both stream consumer instantiation sites:

Proxy/SSE path (line ~15018):

if source.platform == Platform.MATRIX:
    _effective_cursor = ""
    _buffer_only = True          # ← kills progressive edits

Delta/error consumer path (line ~16207):

if source.platform == Platform.MATRIX:
    _effective_cursor = ""
    _buffer_only = True          # ← same

buffer_only = True makes GatewayStreamConsumer skip the interval/threshold flush path (only got_done / segment_break / commentary trigger edits), effectively making Matrix final/split-only.

This guard was added in #10860 ("make buffered streaming") as a defensive measure during the E2EE/migration fix batch.


Fix

Remove both _buffer_only = True lines. The _buffer_only default (False) already set above remains active. Cursor suppression (_effective_cursor = "") is preserved — some Matrix clients render the cursor as a tofu/white-box artifact.

Matrix now receives progressive m.replace edits like other platforms (Discord, Slack, etc.).


How to Test

pytest tests/gateway/test_stream_consumer.py
# ✅ 97 passed

pytest tests/gateway/test_matrix.py::test_edit_payload_uses_m_replace
# ✅ 1 passed — confirms Matrix adapter edit_message produces correct m.replace payloads

pytest tests/gateway/test_matrix.py
# ✅ 67 passed (1 unrelated pre-existing failure in markdown table test)

Checklist

  • Tests pass — 97/97 stream consumer, 67/67 matrix (1 pre-existing unrelated failure)
  • Follows Conventional Commits
  • Changes scoped to this fix only
  • Cursor suppression preserved (_effective_cursor = "")

Risk & Impact

Low. Two-line removal — the _buffer_only default (False) was already set above both removed lines. No logic is added; the guard that was suppressing progressive edits is simply removed. All other platforms are unaffected. The pre-existing markdown table test failure is unrelated and also fails on current main.

Type: 🐛 Bug fix
Closes: #58728

…e m.replace edits

Matrix gateway was forcing buffer_only=True for all Matrix platform
streaming, which silently disabled progressive m.replace edits.
The consumer only delivered final/split messages, never mid-stream
edits — even though direct Matrix API m.replace calls and the
GatewayStreamConsumer with buffer_only=False (fake adapter)
both work correctly.

The buffer_only guard was added in NousResearch#10860 ("make buffered streaming")
as a defensive measure during the E2EE/migration fix batch.

This change removes the forced buffer_only=True from both
stream consumer instantiation sites (proxy path and delta/error
consumer path), reverting Matrix to progressive edit streaming
like other platforms (Discord, Slack, etc.).

Cursor suppression (_effective_cursor="") is preserved to avoid
the visible tofu/white-box artifact on some Matrix clients.

Fixes NousResearch#58728
@Kewe63
Kewe63 requested a review from a team July 5, 2026 09:48
@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery platform/matrix Matrix adapter (E2EE) sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages P3 Low — cosmetic, nice to have labels Jul 5, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Related: #58728 (the issue this fixes) and the Matrix streaming-delivery family #41090 / #37931 / #49815 / #57091 (same area, different mechanisms).

Heads up for reviewers: the live diff on this PR is a whole-fork push (1285 files, +22k/-130k, currently CONFLICTING). The actual described fix is tiny — removing the two _buffer_only = True lines forced only for Platform.MATRIX in gateway/run.py. Please rebase/isolate the real change onto a clean branch off main so it can be reviewed on its own.

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/matrix Matrix adapter (E2EE) 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.

2 participants