Print each SSE data object on its own line in invoke streaming output#7538
Conversation
Fixes Azure#7491 - streaming responses from the invoke command (invocations protocol) now emit a linebreak after each SSE data object instead of concatenating them all on a single line. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR updates the invoke command’s streaming output (invocations protocol over SSE) so each received data: payload is printed on its own line, improving readability and matching the formatting requested in issue #7491.
Changes:
- Change SSE streaming output to emit a newline after each
data:payload (instead of concatenating all payloads onto one line). - Remove now-unnecessary extra newline printing that was previously used to terminate concatenated output.
jongio
left a comment
There was a problem hiding this comment.
Change is correct and minimal. Print to Println gives each SSE data object its own line, which is what #7491 asks for. The two removed if printed { Println() } blocks are now dead code since each line already ends with a newline - good cleanup.
Verified edge cases mentally: empty stream, error-only, error-after-data, DONE signal all behave correctly. The LRO delta handler in the same file intentionally uses the old concatenation pattern (fmt.Print) since those are partial tokens - so no inconsistency here.
Test coverage for stdout output (already flagged in this thread) is the only gap worth tracking.
Refactor handleInvocationSSE to accept an io.Writer parameter so tests can capture output in a bytes.Buffer instead of writing to os.Stdout. The test table now includes wantOutput assertions verifying: - The [agent] prefix appears once on the first line - Each data: line produces a separate output line - DONE stops output, empty streams produce no output - Non-data SSE lines are ignored but data: lines within them are printed Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fixes #7491 - streaming responses from the invoke command (invocations protocol) now emit a linebreak after each SSE data object instead of concatenating them all on a single line.