Join Response.String() messages with a newline like .NET ConcatText - #742
Open
PratikDhanave wants to merge 1 commit into
Open
Join Response.String() messages with a newline like .NET ConcatText#742PratikDhanave wants to merge 1 commit into
PratikDhanave wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns agent.Response.String() output with the .NET ConcatText / AgentResponse.Text behavior by inserting a newline between each non-empty message’s text, instead of concatenating message texts with no separator.
Changes:
- Update
Response.String()to join each non-emptymsg.String()with\nand skip empty messages. - Add black-box tests covering newline joining, skipping empty messages without double newlines, and preserving within-message text concatenation across multiple
TextContentitems.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| agent/response.go | Changes Response.String() to newline-separate non-empty message text using msg.String() (which delegates to message.Contents.Text()). |
| agent/response_test.go | Adds TestResponse_String to validate cross-message newline joining and empty-message skipping while keeping within-message concatenation unchanged. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
Response.String() flattened every message's text into one builder with no separator, so a multi-message assistant turn returned "fooBar" where .NET AgentResponse.Text (backed by ChatMessage list ConcatText) returns "foo\nBar". Join each non-empty per-message text with a newline, skipping empty messages, matching .NET semantics. This also aligns the agent-as-tool result returned by agenttool's FuncTool, which surfaces resp.String().
PratikDhanave
force-pushed
the
response-string-newline-concattext
branch
from
July 24, 2026 09:30
a3831db to
f533990
Compare
Contributor
|
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
gdams
approved these changes
Jul 29, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to a conflict with the base branch
Jul 29, 2026
gdams
enabled auto-merge
July 29, 2026 14:37
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
Response.String()flattened the text of every message into a singlestrings.Builderwith no separator. For a two-message assistant turn (foo,Bar) it returnedfooBar. It now joins each non-empty per-message text with a newline, yieldingfoo\nBar, and skips empty messages so no double newline is produced. Text glued within a single message (multipleTextContentitems) is unchanged.Why (.NET parity)
In microsoft/agent-framework,
AgentResponse.Textis backed bymessages.ConcatText().ConcatText(IList<ChatMessage>)documents that "A newline separator is added between each non-empty piece of text" and usesAppendLinebetween non-empty messages. The Go port glued messages together instead, so the same two-message turn producedfooBarin Go vsfoo\nBarin .NET.The per-message join was already correct:
msg.String()==message.Contents.Text(), the analog ofChatMessage.Text. This change reusesmsg.String()and only fixes the cross-message separator.This also aligns the agent-as-tool result: agenttool's
FuncToolreturnsresp.String()as the tool output, the analog of .NETAsAIFunctionreturningresponse.Text.Testing
Added
TestResponse_Stringinagent/response_test.go(black-box,package agent_test) covering: two single-text messages join with a newline; an empty middle message is skipped without a double newline; multipleTextContentitems within one message stay glued.go build ./...,go vet ./agent/..., andgo test ./agent/...(plus./tool/agenttool/...) pass.