on main help sign in
fix(mcp): tool output join with new line (#686)

* fix(mcp): tool output join with new line refs #604 refs #658 Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> * fix: make Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com> --------- Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

commit073d130b756615c799274187fc1ceb67509edcb7 authorCarlos Alexandro Becker <caarlos0@users.noreply.github.com> dateWed 13 Aug 2025, 15:58 (1 year ago) parent4d63624
1 file changed+4−5
internal/llm/agent/mcp-tools.go+4−5
internal/llm/agent/mcp-tools.go+4−5
@@ -123,16 +123,15 @@ func runTool(ctx context.Context, name, toolName string, input string) (tools.To
123123 return tools.NewTextErrorResponse(err.Error()), nil
124124 }
125125
126− var output strings.Builder
126+ output := make([]string, 0, len(result.Content))
127127 for _, v := range result.Content {
128128 if v, ok := v.(mcp.TextContent); ok {
129− output.WriteString(v.Text)
129+ output = append(output, v.Text)
130130 } else {
131− _, _ = fmt.Fprintf(&output, "%v: ", v)
131+ output = append(output, fmt.Sprintf("%v", v))
132132 }
133133 }
134−
135− return tools.NewTextResponse(output.String()), nil
134+ return tools.NewTextResponse(strings.Join(output, "\n")), nil
136135}
137136
138137func (b *McpTool) Run(ctx context.Context, params tools.ToolCall) (tools.ToolResponse, error) {