microsoft / microsoft/agent-framework
.NET: ChatClientAgent returns first line only
- 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.
I'm not sure if I misconfigured something, but when I tested directly with Ollama or HttpClient, I received the complete answer.
I'm unsure what the issue could be. Any help would be appreciated.
Contributor guide
Assessment
This issue has not been assessed yet.