Skip to content

.Net: Bug: Unexpected Accumulation of Previous Assistant Messages in Final Response Using InvokeStreamingAsync #12485

Open
@nels-ai-source

Description

@nels-ai-source

Describe the bug
When using the InvokeStreamingAsync method of ChatCompletionAgent, and receiving multi-turn conversation responses in the OnIntermediateMessage, it was found that the final assistant message included previous assistant messages. It appears that the last message accumulates all previous assistant messages. I am not sure if this is a bug, but it has caused confusion during usage.

To Reproduce
Steps to reproduce the behavior:

Define a ChatAgent with provided tools.

ChatCompletionAgent agent = new()
{
    Instructions = processRequest.AgentRequest.Instructions,
    Kernel = processRequest.Kernel,
    HistoryReducer = new ChatHistoryTruncationReducer(6, 4),
    Arguments = new KernelArguments(new OpenAIPromptExecutionSettings
    {
        Temperature = 0,
        FunctionChoiceBehavior = FunctionChoiceBehavior.Auto(functions: processRequest.AgentRequest.Functions, autoInvoke: processRequest.AgentRequest.Functions?.Count > 0, options: new() { RetainArgumentTypes = true })
    })
};

Receive messages in OnIntermediateMessage and notice overlapping data.
Expected behavior
Each message should be independent and non-repetitive.

Platform

Language: C#
Source: 1.56.0
IDE: Visual Studio
OS: Windows

Metadata

Metadata

Assignees

Labels

.NETIssue or Pull requests regarding .NET codeagentsbugSomething isn't working

Type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions