Skip to content

Print each SSE data object on its own line in invoke streaming output#7538

Merged
rajeshkamal5050 merged 2 commits into
Azure:mainfrom
therealjohn:fix/invoke-streaming-linebreaks
Apr 9, 2026
Merged

Print each SSE data object on its own line in invoke streaming output#7538
rajeshkamal5050 merged 2 commits into
Azure:mainfrom
therealjohn:fix/invoke-streaming-linebreaks

Conversation

@therealjohn

Copy link
Copy Markdown
Contributor

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.

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>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread cli/azd/extensions/azure.ai.agents/internal/cmd/invoke.go Outdated
@JeffreyCA JeffreyCA assigned JeffreyCA and unassigned JeffreyCA Apr 6, 2026

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@rajeshkamal5050
rajeshkamal5050 merged commit 6f0ed59 into Azure:main Apr 9, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

improve formatting of invocations streaming responses

7 participants