microsoft / microsoft/agent-framework

.NET: ChatClientAgent returns first line only

Open
#2,817 1 comment 0 reactions 1 assignee Claimed by @rogerbarreto View on GitHub
.NET agents
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

Hi all,
I've installed Ollama on my local Windows machine and tried to create a simple agent using the following code.

```csharp
using Microsoft.Extensions.AI;
using OpenAI;
using OpenAI.Chat;
using System.ClientModel;

var openAIClient = new ChatClient(
model: "gemma3:270m",
credential: new ApiKeyCredential("your_api_key"),
options: new OpenAIClientOptions()
{
Endpoint = new Uri("http://localhost:11434/v1/")
}
);

var agent = openAIClient.CreateAIAgent("You are good at telling jokes", "joker");

try
{
var prompt = "Tell me a joke about a pirate.";
Console.WriteLine(await agent.RunAsync(prompt));
}
catch (Exception ex)
{
Console.WriteLine($"Error: {ex.Message}");
}

Console.ReadLine();
```

Project file

```xml


Exe
net10.0
enable
enable




```

However, the RunAsync or RunStreamingAsync function only returns the first line of the response.

Image

I'm not sure if I misconfigured something, but when I tested directly with Ollama or HttpClient, I received the complete answer.

Image

Image

I'm unsure what the issue could be. Any help would be appreciated.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.