Skip to content

fix(gateway): do not drop final reply after session split#14391

Open
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/fix-14238-session-split-delivery
Open

fix(gateway): do not drop final reply after session split#14391
sgaofen wants to merge 1 commit into
NousResearch:mainfrom
sgaofen:codex/fix-14238-session-split-delivery

Conversation

@sgaofen

@sgaofen sgaofen commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Fixes #14238.

Root cause

Gateway delivery suppression treated response_previewed=True as proof that the final reply had reached the user. During compression/session handoff, unrelated interim commentary could be delivered while the actual final response still needed the normal platform send path. That left the response persisted in the child session but not sent to chat.

Fix

  • Track exact commentary text delivered by GatewayStreamConsumer.
  • Only suppress the normal final send when the stream consumer confirms final delivery, or when the exact final response text was already delivered as a preview.
  • Apply the same guard before processing queued follow-up messages so the first response is not skipped at a session boundary.

Tests

  • python -m pytest tests/gateway/test_run_progress_topics.py::test_run_agent_previewed_final_marks_already_sent tests/gateway/test_run_progress_topics.py::test_run_agent_previewed_split_keeps_final_delivery_pending tests/gateway/test_run_progress_topics.py::test_run_agent_queued_message_does_not_treat_commentary_as_final tests/gateway/test_run_progress_topics.py::test_run_agent_streaming_does_not_enable_completed_interim_commentary tests/gateway/test_stream_consumer.py::TestInterimCommentaryMessages -q --tb=short
  • python -m pytest tests/gateway/test_run_progress_topics.py tests/gateway/test_stream_consumer.py -q --tb=short
  • git diff --check

Note: the current full-suite baseline on main is covered by #13352, which is green and mergeable. If this PR shows the same unrelated full-suite failures before #13352 lands, the targeted regression coverage above is the relevant signal for this patch.

@sgaofen

sgaofen commented Apr 23, 2026

Copy link
Copy Markdown
Contributor Author

CI note: I checked the failing test job and it matches the current-main baseline failures covered by #13352 (for example fallback-chain/tips/browser-cdp/write-deny/zombie-cleanup signatures).

Local validation for this PR remains green:

  • python -m pytest tests/gateway/test_run_progress_topics.py::test_run_agent_previewed_final_marks_already_sent tests/gateway/test_run_progress_topics.py::test_run_agent_previewed_split_keeps_final_delivery_pending tests/gateway/test_run_progress_topics.py::test_run_agent_queued_message_does_not_treat_commentary_as_final tests/gateway/test_run_progress_topics.py::test_run_agent_streaming_does_not_enable_completed_interim_commentary tests/gateway/test_stream_consumer.py::TestInterimCommentaryMessages -q --tb=short -> 7 passed
  • python -m pytest tests/gateway/test_run_progress_topics.py tests/gateway/test_stream_consumer.py -q --tb=short -> 99 passed
  • git diff --check

Once #13352 lands, I can rebase/rerun this branch if needed.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery labels Apr 23, 2026
@Bartok9

Bartok9 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

I rechecked this against current origin/main (88b6eb9a). The response_previewed=True suppression logic in the gateway delivery path is unchanged from the issue description — confirmed the bug is still present. The fix correctly separates interim commentary delivery from final response delivery in the session-split path.

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 P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pending response lost when session split occurs at response boundary

3 participants