feat(moa): stream the aggregator response to the user - #53848
Closed
lEWFkRAD wants to merge 1 commit into
Closed
Conversation
MoA sessions could not stream: the gateway streaming toggle was a no-op for
provider "moa", so users saw nothing until the entire response finished — minutes
of silence on long turns. The aggregator's reply was always fetched whole.
Root cause was twofold:
1. conversation_loop hard-disabled streaming for provider in {"copilot-acp",
"moa"} (MoA grouped with the ACP client, whose facade isn't a stream).
2. MoAChatCompletions.create() fetched the aggregator response whole via
call_llm(), which had no streaming mode.
For provider "moa", _create_request_openai_client() returns the MoAClient facade
itself, so the existing streaming consumer already calls
MoAChatCompletions.create(stream=True). We reuse that battle-tested consumer
(text-delta delivery, tool_call reassembly, stale-stream detection, non-streaming
fallback) instead of adding a parallel streaming path.
Changes:
- call_llm() gains stream/stream_options. When streaming it returns the raw SDK
stream iterator directly, bypassing _validate_llm_response and the
temperature/max_tokens/payment fallback chain (which assume a complete
response). The caller owns reassembly and fallback.
- MoAChatCompletions.create() runs the references first (unchanged), then when
stream=True returns the aggregator's raw stream, forwarding stream_options and
the consumer's per-request read timeout. stream=False is byte-identical to
before (no stream/stream_options/timeout forwarded).
- conversation_loop streams MoA only when a display/TTS consumer is present;
quiet/subagent/health-check paths keep the complete-response path.
Tests: tests/run_agent/test_moa_streaming.py — create() stream/non-stream
branches, stream_options + timeout forwarding, call_llm raw-stream return vs
validated non-stream. Existing MoA tests unchanged (20 passed).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
tonydwb
approved these changes
Jun 28, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
MoA aggregator streaming response (4 files). Clean feature extension:
- New
streamandstream_optionsparameters oncall_llm - Streaming path returns raw SDK iterator directly (bypasses response validation)
- Conversation loop integration for streaming MoA aggregator output
- Clear docstring explaining the streaming contract and fallback ownership
Well-scoped streaming extension. The deliberate skip of validation on the streaming path is correct — the caller owns chunk reassembly.
teknium1
added a commit
that referenced
this pull request
Jun 30, 2026
Contributor
|
Merged via #55625 — your commit was cherry-picked onto current main with your authorship preserved in git log (commit on main under your name). One small conflict resolved during salvage: the call_llm signature also gained an api_mode kwarg from an earlier MoA fix (#55579), so both kwargs now coexist. Thanks for the clean, low-risk approach — reusing the existing streaming consumer was exactly right. |
dtera
pushed a commit
to dtera/hermes-agent
that referenced
this pull request
Jul 1, 2026
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Jasper6439
pushed a commit
to Jasper6439/hermes-agent
that referenced
this pull request
Jul 5, 2026
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
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?
Makes Mixture-of-Agents (MoA) sessions stream the aggregator's response to the
user. Today MoA can't stream: the gateway streaming toggle is a no-op for
provider: moa, so the user sees nothing until the entire response finishes —minutes of silence on long turns — because the aggregator's reply is always
fetched whole.
Two causes: (1)
conversation_loophard-disables streaming forprovider in {"copilot-acp", "moa"}, and (2)MoAChatCompletions.create()fetches the aggregator response whole via
call_llm(), which had no streamingmode.
For
provider: moa,_create_request_openai_client()returns theMoAClientfacade itself, so the existing streaming consumer already invokes
MoAChatCompletions.create(stream=True). This PR reuses that battle-testedconsumer (text-delta delivery, tool-call reassembly, stale-stream detection,
non-streaming fallback) rather than adding a parallel streaming path — so the
change is small and low-risk.
Related Issue
No existing issue — happy to open one if preferred.
Fixes #
Type of Change
Changes Made
agent/auxiliary_client.py—call_llm()gainsstream/stream_options.When streaming it returns the raw SDK stream iterator directly, bypassing
_validate_llm_responseand the temperature/max_tokens/payment fallback chain(which assume a complete response). The caller owns reassembly and fallback.
agent/moa_loop.py—MoAChatCompletions.create()runs the references first(unchanged), then when
stream=Truereturns the aggregator's raw stream,forwarding
stream_optionsand the consumer's per-request read timeout.stream=Falseis byte-identical to before (no stream/stream_options/timeoutforwarded).
agent/conversation_loop.py— MoA streams only when a display/TTS consumer ispresent; quiet/subagent/health-check paths keep the complete-response path,
preserving prior behavior (and the existing
_create_request_openai_clientguard test).
tests/run_agent/test_moa_streaming.py— new tests (below).How to Test
provider: moa) with adisplay consumer attached — the aggregator's output now appears
incrementally instead of all at once when the turn completes.
that tool-calling still works under streaming (the reused consumer reassembles
tool_calls).pytest tests/run_agent/test_moa_streaming.py tests/run_agent/test_moa_loop_mode.py -qChecklist
Code
feat(moa): ...)pytest tests/ -qand all tests pass (the MoA suites; 20 passed)Documentation & Housekeeping
call_llmand thechanged methods) — no user-facing docs reference MoA streaming
cli-config.yaml.exampleif I added/changed config keys — N/A(no new config keys; reuses existing streaming behavior)
CONTRIBUTING.mdorAGENTS.mdif I changed architecture orworkflows — N/A
Screenshots / Logs
Verified live on a local llama.cpp MoA stack: a plain turn streamed 74 incremental
content chunks (previously one buffered block); references still fired; a
tool-calling turn streamed and executed the tool with no errors.