Fix: Add iteration boundary linebreak to prevent stream concatenation… - #2187
Closed
devorun wants to merge 1 commit into
Closed
Fix: Add iteration boundary linebreak to prevent stream concatenation…#2187devorun wants to merge 1 commit into
devorun wants to merge 1 commit into
Conversation
… after tool calls Fixes NousResearch#2177 When streaming is enabled, the `GatewayStreamConsumer` continuously appends text to a single buffer. Previously, when the agent paused to execute tool calls and then resumed streaming, the new text was concatenated directly onto the prior text without any separation, resulting in unreadable formatting. This PR adds a simple `self._fire_stream_delta("\n\n")` signal immediately after `_execute_tool_calls()` in `run_agent.py`. This ensures a clean paragraph break is inserted into the stream buffer whenever an iteration boundary occurs, fixing the multi-iteration formatting on platforms like Telegram and Discord
Contributor
|
Merged via PR #2413. Cherry-picked with authorship preserved. Thanks! |
TheBlueHouse75
pushed a commit
to TheBlueHouse75/hermes-agent
that referenced
this pull request
Mar 22, 2026
Cherry-picked from PR NousResearch#2187 by @devorun. Fixes NousResearch#2177. When streaming is enabled, text before and after tool calls gets concatenated without separation. Adds a paragraph break delta after _execute_tool_calls() so stream consumers insert proper whitespace between iteration boundaries.
MacroAnarchy
added a commit
to MacroAnarchy/hermes-agent
that referenced
this pull request
Mar 22, 2026
Follow-up to 669c60a (cherry-pick of PR NousResearch#2187, fixes NousResearch#2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
teknium1
pushed a commit
that referenced
this pull request
Mar 22, 2026
Follow-up to 669c60a (cherry-pick of PR #2187, fixes #2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
outsourc-e
pushed a commit
to outsourc-e/hermes-agent
that referenced
this pull request
Mar 26, 2026
Cherry-picked from PR NousResearch#2187 by @devorun. Fixes NousResearch#2177. When streaming is enabled, text before and after tool calls gets concatenated without separation. Adds a paragraph break delta after _execute_tool_calls() so stream consumers insert proper whitespace between iteration boundaries.
outsourc-e
pushed a commit
to outsourc-e/hermes-agent
that referenced
this pull request
Mar 26, 2026
Follow-up to 669c60a (cherry-pick of PR NousResearch#2187, fixes NousResearch#2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 27, 2026
Cherry-picked from PR NousResearch#2187 by @devorun. Fixes NousResearch#2177. When streaming is enabled, text before and after tool calls gets concatenated without separation. Adds a paragraph break delta after _execute_tool_calls() so stream consumers insert proper whitespace between iteration boundaries.
angelburgosrosado
pushed a commit
to angelburgosrosado/hermes-agent
that referenced
this pull request
Apr 27, 2026
Follow-up to 72e51b6 (cherry-pick of PR NousResearch#2187, fixes NousResearch#2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
Cherry-picked from PR NousResearch#2187 by @devorun. Fixes NousResearch#2177. When streaming is enabled, text before and after tool calls gets concatenated without separation. Adds a paragraph break delta after _execute_tool_calls() so stream consumers insert proper whitespace between iteration boundaries.
02356abc
pushed a commit
to 02356abc/hermes-agent
that referenced
this pull request
May 14, 2026
Follow-up to 669c60a (cherry-pick of PR NousResearch#2187, fixes NousResearch#2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
Cherry-picked from PR NousResearch#2187 by @devorun. Fixes NousResearch#2177. When streaming is enabled, text before and after tool calls gets concatenated without separation. Adds a paragraph break delta after _execute_tool_calls() so stream consumers insert proper whitespace between iteration boundaries.
gweeteve
pushed a commit
to gweeteve/hermes-agent
that referenced
this pull request
Jun 2, 2026
Follow-up to 669c60a (cherry-pick of PR NousResearch#2187, fixes NousResearch#2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Cherry-picked from PR NousResearch#2187 by @devorun. Fixes NousResearch#2177. When streaming is enabled, text before and after tool calls gets concatenated without separation. Adds a paragraph break delta after _execute_tool_calls() so stream consumers insert proper whitespace between iteration boundaries.
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Follow-up to 21e96ba (cherry-pick of PR NousResearch#2187, fixes NousResearch#2177). The original fix emits a "\n\n" delta immediately after every _execute_tool_calls() invocation. When the model runs multiple consecutive tool iterations before producing text (common with search → read → analyze flows), each iteration appends its own paragraph break, resulting in 4-6+ blank lines before the actual response. Replace the immediate delta with a deferred flag (_stream_needs_break). _fire_stream_delta() checks the flag and prepends a single "\n\n" only when the first real text delta arrives, so multiple back-to-back tool iterations still produce exactly one paragraph break.
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.
… after tool calls
Fixes #2177
When streaming is enabled, the
GatewayStreamConsumercontinuously appends text to a single buffer. Previously, when the agent paused to execute tool calls and then resumed streaming, the new text was concatenated directly onto the prior text without any separation, resulting in unreadable formatting.This PR adds a simple
self._fire_stream_delta("\n\n")signal immediately after_execute_tool_calls()inrun_agent.py. This ensures a clean paragraph break is inserted into the stream buffer whenever an iteration boundary occurs, fixing the multi-iteration formatting on platforms like Telegram and DiscordWhat does this PR do?
Related Issue
Fixes #
Type of Change
Changes Made
How to Test
Checklist
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/AFor New Skills
hermes --toolsets skills -q "Use the X skill to do Y"Screenshots / Logs