fix(gateway): inject newline separator at stream iteration boundaries - #2376
Closed
sprmn24 wants to merge 1 commit into
Closed
fix(gateway): inject newline separator at stream iteration boundaries#2376sprmn24 wants to merge 1 commit into
sprmn24 wants to merge 1 commit into
Conversation
Treat stream_delta_callback(None) as an iteration boundary signal in GatewayStreamConsumer.on_delta(). When the accumulated buffer does not end with a newline, inject one so resumed text after tool calls starts on a new line instead of being concatenated directly. Closes NousResearch#2177
1 task
Contributor
Author
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes a bug where resumed streamed text after tool calls was concatenated directly onto prior content with no separator, making multi-iteration responses unreadable.
Related Issue
Closes #2177
Type of Change
Changes Made
gateway/stream_consumer.py: Updatedon_delta()to treatNoneas an iteration boundary signal. WhenNoneis received and the buffer does not already end with a newline, a separator is injected into the queue.tests/gateway/test_stream_consumer.py: New test file — 8 tests covering the boundary injection logic, including the exact regression case from this issue.No changes to
run_agent.py— it already emitsstream_delta_callback(None)at the right point; the consumer just wasn't handling it.How to Test
streaming.enabled: truein config.yaml)python3 -m pytest tests/gateway/test_stream_consumer.py -vChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
8/8 tests passing:
python3 -m pytest tests/gateway/test_stream_consumer.py -v