microsoft / microsoft/semantic-kernel

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

Open
#12,485 7 comments 1 reaction 1 assignee View on GitHub

Nobody has claimed this yet.

.NET agents bug
Dominant language
C#
Stars
28.6k
Forks
4.8k
Avg merge
14h 13m
Merged PRs (30d)
18

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.