-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Labels
.NETv1.0Features being tracked for the version 1.0 GAFeatures being tracked for the version 1.0 GAworkflowsRelated to Workflows in agent-frameworkRelated to Workflows in agent-framework
Description
Issue Summary
When implementing the Handoff workflow in the Microsoft Agent Framework using the official documentation example and Workflow as Agent pattern, only user messages are recorded in the thread. Assistant responses are not stored.
Expected Behavior
Both user and assistant messages should be stored to ensure a complete conversation history.
Actual Behavior
Only user messages appear in the log; assistant messages are missing.
Reproduction Steps
- Use the Handoff workflow example provided in the official Microsoft documentation but with Workflow as Agent as a result.
- Trigger a handoff scenario.
- Review the stored conversation history in thread.
Impact
Incomplete history limits context availability for agents and affects traceability.
Please advise whether assistant message logging can be enabled or if this is an unintended limitation.
Code snippet:
static async Task Main(string[] args)
{
var client = new AzureOpenAIClient(new Uri(""),
new System.ClientModel.ApiKeyCredential(""))
.GetChatClient("gpt-5-mini")
.AsIChatClient();
ChatClientAgent historyTutor = new(client,
"You provide assistance with historical queries. Explain important events and context clearly. Only respond about history.",
"history_tutor",
"Specialist agent for historical questions");
ChatClientAgent mathTutor = new(client,
"You provide help with math problems. Explain your reasoning at each step and include examples. Only respond about math.",
"math_tutor",
"Specialist agent for math questions");
ChatClientAgent triageAgent = new(client,
"You determine which agent to use based on the user's homework question. ALWAYS handoff to another agent.",
"triage_agent",
"Routes messages to the appropriate specialist agent");
var workflowAgent = AgentWorkflowBuilder.CreateHandoffBuilderWith(triageAgent)
.WithHandoffs(triageAgent, [mathTutor, historyTutor])
.WithHandoff(mathTutor, triageAgent)
.WithHandoff(historyTutor, triageAgent)
.Build()
.AsAgent();
var workflowAgentThread = workflowAgent.GetNewThread();
while (true)
{
Console.WriteLine();
Console.Write("User (or 'exit' to quit): ");
string? input = Console.ReadLine();
if (string.IsNullOrWhiteSpace(input) || input.Equals("exit", StringComparison.OrdinalIgnoreCase))
{
break;
}
await ProcessInputAsync(workflowAgent, workflowAgentThread, input);
}
}
static async Task ProcessInputAsync(AIAgent agent, AgentThread thread, string input)
{
Dictionary<string, List<AgentRunResponseUpdate>> buffer = [];
await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync(input, thread))
{
if (update.MessageId is null || string.IsNullOrEmpty(update.Text))
{
// skip updates that don't have a message ID or text
continue;
}
if (!buffer.TryGetValue(update.MessageId, out List<AgentRunResponseUpdate>? value))
{
value = [];
buffer[update.MessageId] = value;
}
value.Add(update);
foreach (var (messageId, segments) in buffer)
{
string combinedText = string.Concat(segments);
Console.WriteLine($"{segments[0].AuthorName}: {combinedText}");
Console.WriteLine();
}
}
}

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
.NETv1.0Features being tracked for the version 1.0 GAFeatures being tracked for the version 1.0 GAworkflowsRelated to Workflows in agent-frameworkRelated to Workflows in agent-framework
Type
Projects
Status
In Review