microsoft / microsoft/semantic-kernel
.Net: Bug: Unexpected Accumulation of Previous Assistant Messages in Final Response Using InvokeStreamingAsync
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.