Skip to content

fix(gateway): use buffer_only mode for Photon to prevent streaming cursor tofu - #49815

Closed
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/49793-photon-buffer-only
Closed

fix(gateway): use buffer_only mode for Photon to prevent streaming cursor tofu#49815
liuhao1024 wants to merge 1 commit into
NousResearch:mainfrom
liuhao1024:fix/49793-photon-buffer-only

Conversation

@liuhao1024

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds Photon (iMessage) to the buffer_only streaming mode check so the streaming cursor character is suppressed. Previously, the cursor rendered as a visible white-square/tofu artifact in iMessage bubbles.

Related Issue

Fixes #49793

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • gateway/run.py: Add Photon to the buffer_only=True condition in both streaming code paths (the _run_agent path and the inline-streaming path), alongside the existing Matrix check. Uses getattr(source.platform, "value", "") == "photon" since Photon is a plugin platform without an explicit enum member.
  • tests/gateway/test_run_progress_topics.py: Add test_run_agent_photon_streaming_buffer_only regression test verifying no streaming cursor artifact and no intermediate edits for Photon sessions.

How to Test

  1. Configure a Photon/iMessage gateway adapter
  2. Send a message that triggers streaming response
  3. Verify no white-square characters appear in the iMessage bubble
  4. Run pytest tests/gateway/test_run_progress_topics.py::test_run_agent_photon_streaming_buffer_only -xvs
  5. Run pytest tests/gateway/test_run_progress_topics.py::test_run_agent_matrix_streaming_omits_cursor -xvs (regression: Matrix still works)
  6. Run pytest tests/gateway/test_stream_consumer.py::TestBufferOnlyMode -xvs (regression: buffer_only mode tests still pass)

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

Documentation & Housekeeping

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

Code Intelligence

  • Analyzed: gateway/run.py lines 13947-13957 and 15114-15124 (streaming buffer_only logic)
  • Blast radius: LOW — additive condition to existing platform check, no control flow change
  • Related patterns: Matrix buffer_only (same mechanism, line 13949/15115), StreamConsumerConfig buffer_only mode

…rsor tofu

iMessage renders the streaming cursor as a visible white-square artifact.
Add Photon to the buffer_only platform check (alongside Matrix) so only
the final plain-text message is delivered without intermediate cursor
characters.

Fixes NousResearch#49793

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused Photon streaming fix. Current main still defaults Photon to editable behavior at gateway/run.py:16751-16756 and gateway/run.py:18079-18089, so the two affected stream-consumer construction sites remain live.

Problems

  • The added comments say buffer-only mode produces a final plain-text-only message. GatewayStreamConsumer still flushes on segment breaks and commentary (gateway/stream_consumer.py:625-630), while Photon preserves markdown by default (plugins/platforms/photon/adapter.py:1384-1390, 1481-1484).

Suggested changes

  • Reword the two comments to describe cursor suppression and the absence of interval/threshold-driven updates, without promising forced plain text or universally final-only output.

The surrounding code has moved, but the two-hunk fix remains mechanically salvageable. Automated hermes-sweeper review.

Comment thread gateway/run.py
# streaming cursor as a visible tofu/white-box
# artifact. Suppress the cursor and use buffer-only
# mode so only the final plain-text message is sent.
if source.platform == Platform.MATRIX or getattr(source.platform, "value", "") == "photon":

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

buffer_only suppresses interval/threshold flushes, but it still flushes on segment breaks and commentary; Photon also retains markdown by default. Please reword the surrounding comment to avoid promising a universally final-only plain-text message.

@teknium1 teknium1 added sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform area/streaming Streaming responses: gateway delivery, provider wire labels Jul 14, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Closing in favor of #62172 (same author) — the SUPPORTS_MESSAGE_EDITING capability flag is the convention-correct mechanism and landed via #73560. Thanks for both takes on this bug.

@teknium1 teknium1 closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/streaming Streaming responses: gateway delivery, provider wire comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:blast-moderate Sweeper blast radius: moderate — a subsystem or single platform sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades 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.

Photon iMessage: streaming cursor/tofu shows as white square in outbound messages

3 participants