Description
Version
What package version of the SDK are you using.
- Nuget package version: 1.1.107-beta
Describe the bug
Proactive messages sent using adapter.CreateConversationAsync
are not stored in ITurnState
and are not logged using FileTranscriptLogger
.
This is a problem when creating an AI agent that sends the outcome of a document analysis to a new conversation, where the user expects to be able to ask followup-questions about said outcome. Without that context, the bot will just ask the user to repeat what the bot just sent before.
To Reproduce
How can we reproduce this error?
- Create an agent, e.g. from the weather agent sample.
- Setup
BlobsStorage
for the state (I used Azurite for this) - Setup transcript logging using
builder.Services.AddSingleton<Microsoft.Agents.Builder.IMiddleware[]>([new TranscriptLoggerMiddleware(new FileTranscriptLogger())]);
- Set a breakpoint in the
MessageActivityAsync
method of yourAgentApplication
and prepare to inspect the chat history fromITurnState
- see this lineChatHistory chatHistory = turnState.GetValue("conversation.chatHistory", () => new ChatHistory());
- Let it send a proactive message in a team channel or in a 1:1 conversation. Make sure to send 2 activities:
- one via the
ConversationParameters.Activity
parameter - one via the
CreateConversationAsync
callback
parameter
- one via the
- From a user perspective, send a message in the same conversation.
- When the breakpoint hits, inspect the chat history and the
ITurnState
object.⚠️ The proactive message is not available there - neither theConversationParameters.Activity
parameter nor theCreateConversationAsync
callback
parameter - Let the debugger continue
- Inspect the file written by the
FileTranscriptLogger
. The proactive message is missing from the conversation.lease provide Code Snippets, Channel type, and any special configuration we will need to reproduce this problem.I used this code for the team channel conversation:
var adapter = this.Options.Adapter;
var agentAppId = "10deff5c-1eb5-48ff-a1aa-7378cd8cb4eb";
var tenantId = "<redacted>";
var agentId = "28:10deff5c-1eb5-48ff-a1aa-7378cd8cb4eb";
// Find this using Get-TeamChannel in PowerShell or Graph API
var channelId = "19:2880e0719d0541f5bef37bd1fd151fa2@thread.tacv2"; // Channel ID where the agent is registered
var message = Activity.CreateMessageActivity();
message.Text = "New project document received";
var conversationParameters = new ConversationParameters(
isGroup: true,
agent: new ChannelAccount(id: agentId), // ID of your agent registered in teams.
tenantId: tenantId,
channelData: new TeamsChannelData
{
Channel = new ChannelInfo(channelId),
},
topicName: "Test thread",
activity: (Activity)message
);
try
{
await adapter.CreateConversationAsync(
agentAppId, // ID of the agent your sending too.
"msteams", // ChannelID
"https://smba.trafficmanager.net/emea/", // TeamsProactiveServiceEndpoints.publicGlobal, // Endpoint for the global teams service.
"https://api.botframework.com/.default", // Scope for creating an access token for Teams
conversationParameters, // ConversationParameters Created above.
callback,
default);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
Expected behavior
Messages sent using the CreateConversationAsync method become available in followup turns via ITurnState / chat history.
This is expected for both
- the activity added to the
ConversationParameters.Activity
parameter - the activity sent via the
CreateConversationAsync
callback
parameter
Screenshots
If applicable, add screenshots to help explain your problem.
Hosting Information (please complete the following information):
- How are you Hosting this: [e.g. Azure, Desktop, Other] Desktop (local via .NET Aspire (C# Projects and Docker)
- Are you deploying: no, only local via .NET Aspire (C# Projects and Docker
- Are you using Azure Bot Services: yes
- What Client are you using: Teams
- What .net version is your build in: .net 9.0 / .net 10
Additional context
Add any other context about the problem here.