Description
I'm trying to use MAF against OpenAI Responses API, i.e. a service that stores history. I'm seeing InMemoryChatHistoryProvider storing messages in the session.
My understanding was that in this case the in memory provider should "disengage" and the session should only store the conversation/response id. I must be doing something wrong, because this fundamental scenario appears to be broken.
Code Sample
This test fails on the last assert (hasInMemoryHistory is true):
using System.ClientModel.Primitives;
using Azure.Identity;
using Microsoft.Agents.AI;
using OpenAI;
using OpenAI.Responses;
using Xunit;
namespace MafBug.Tests;
#pragma warning disable OPENAI001
public sealed class InMemoryChatHistoryProviderBugTests
{
const string Endpoint = "https://xxx.services.ai.azure.com/openai/v1";
const string Model = "gpt-5-mini";
[Fact]
public async Task ResponsesApi_DoesNotPopulateInMemoryChatHistoryProvider()
{
var cancellationToken = TestContext.Current.CancellationToken;
var openai = new OpenAIClient(
new BearerTokenPolicy(new DefaultAzureCredential(), scope: "https://ai.azure.com/.default"),
new OpenAIClientOptions { Endpoint = new Uri(Endpoint) });
var responsesClient = openai.GetResponsesClient();
var agent = responsesClient.AsAIAgent(
model: Model,
instructions: "You are a helpful assistant. Respond with very short answers.",
name: "ResponsesAgent");
var session = await agent.CreateSessionAsync(cancellationToken);
var r1 = await agent.RunAsync("Hi", session, cancellationToken: cancellationToken);
var typedSession = Assert.IsType<ChatClientAgentSession>(session);
Assert.False(
string.IsNullOrWhiteSpace(typedSession.ConversationId),
"ChatClientAgentSession.ConversationId is empty.");
var hasInMemoryHistory = session.TryGetInMemoryChatHistory(out var inMemoryMessages);
var storedCount = inMemoryMessages?.Count ?? 0;
Assert.False(
hasInMemoryHistory,
$"BUG: InMemoryChatHistoryProvider stored {storedCount} message(s) in " +
$"the session even though the OpenAI Responses API is storing " +
$"conversation '{typedSession.ConversationId}' server-side. ");
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.21.0" />
<PackageReference Include="Microsoft.Agents.AI" Version="1.7.0" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" Version="1.7.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.5.1" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5" />
</ItemGroup>
</Project>
Error Messages / Stack Traces
Package Versions
1.7.0, also checked 1.6.2
.NET Version
.net10
Additional Context
No response
Description
I'm trying to use MAF against OpenAI Responses API, i.e. a service that stores history. I'm seeing InMemoryChatHistoryProvider storing messages in the session.
My understanding was that in this case the in memory provider should "disengage" and the session should only store the conversation/response id. I must be doing something wrong, because this fundamental scenario appears to be broken.
Code Sample
This test fails on the last assert (
hasInMemoryHistoryistrue):Error Messages / Stack Traces
Package Versions
1.7.0, also checked 1.6.2
.NET Version
.net10
Additional Context
No response