Skip to content

fix(gateway): preserve final delivery on non-editable streams - #58929

Open
devatnull wants to merge 1 commit into
NousResearch:mainfrom
devatnull:fix/noneditable-final-delivery
Open

fix(gateway): preserve final delivery on non-editable streams#58929
devatnull wants to merge 1 commit into
NousResearch:mainfrom
devatnull:fix/noneditable-final-delivery

Conversation

@devatnull

Copy link
Copy Markdown
Contributor

Summary

  • skip gateway streaming previews for non-editable adapters in the proxy path
  • preserve final delivery on WhatsApp/Signal-style transports by letting the normal final send path run once
  • add direct and proxy regression coverage for non-editable streaming

Why

Non-editable messaging platforms cannot replace a stream preview with the final answer. If a preview is sent first, final delivery can be suppressed or duplicated. The direct agent path already guarded this; this PR applies the same guard to proxy-mode streaming and tests both paths.

Test plan

  • python3 -m pytest tests/gateway/test_run_progress_topics.py::test_proxy_non_editable_streaming_uses_final_delivery_only tests/gateway/test_run_progress_topics.py::test_run_agent_non_editable_streaming_uses_final_delivery_only -q
  • scripts/run_tests.sh tests/gateway/test_run_progress_topics.py -q
  • python3 -m py_compile gateway/run.py tests/gateway/test_run_progress_topics.py
  • git diff --check origin/main...HEAD

Copilot AI 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.

Pull request overview

This PR aligns proxy-mode streaming behavior with the existing direct-agent behavior for non-editable messaging adapters, preventing streaming “preview” deliveries that can’t be edited into a final message on platforms without message-edit support.

Changes:

  • Skip gateway stream-consumer setup for adapters that don’t support message editing in the proxy streaming path.
  • Add regression tests covering both direct and proxy execution paths to ensure non-editable adapters do not receive progressive streaming sends and that final delivery remains eligible to run once.
  • Validate proxy SSE parsing still produces the correct assembled final_response while reporting response_previewed=False when previews are suppressed.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
gateway/run.py Disables proxy-path streaming previews on non-editable adapters so final delivery isn’t suppressed/duplicated.
tests/gateway/test_run_progress_topics.py Adds direct + proxy regression coverage ensuring non-editable adapters do not receive streaming preview sends.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alt-glitch alt-glitch added type/bug Something isn't working comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages labels Jul 5, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused proxy-path fix. Current main still constructs a GatewayStreamConsumer for non-editable adapters in proxy mode at gateway/run.py:17023-17055; the consumer can send a first streamed chunk through adapter.send() (gateway/stream_consumer.py:928-942). The proxy result then reports response_previewed when that consumer exists (gateway/run.py:17188-17199).

The proposed guard matches the existing direct-agent behavior at gateway/run.py:18347-18354, and the added proxy regression test covers the previously unguarded path. The only production construction sites are the proxy and direct paths (rg -n 'GatewayStreamConsumer\\('); the direct path is already guarded.

Automated hermes-sweeper review.

@teknium1 teknium1 added the sweeper:blast-contained Sweeper blast radius: contained — one narrow path / opt-in / few users label Jul 15, 2026
@devatnull
devatnull force-pushed the fix/noneditable-final-delivery branch from 82b3ef0 to 20b1dff Compare July 16, 2026 10:04
@teknium1 teknium1 added the area/streaming Streaming responses: gateway delivery, provider wire label Jul 19, 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-contained Sweeper blast radius: contained — one narrow path / opt-in / few users 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.

4 participants