-
Notifications
You must be signed in to change notification settings - Fork 439
Description
[.NET] Missing unified interface for AIAgent with memory, tools, and structured output
Problem Description
The Microsoft Agent Framework .NET implementation lacks a unified interface that allows developers to use memory, function tools, and structured output together with a single agent type. Currently, developers must choose between:
- AIAgent: Supports memory (via
AIContextProviderFactory
) and tools, but lacks structured output (RunAsync<T>
) - ChatClientAgent: Supports structured output (
RunAsync<T>
) but cannot use memory components
This architectural limitation forces developers into suboptimal solutions and prevents the framework from supporting common AI agent patterns that require all three capabilities simultaneously.
Current State Analysis
AIAgent (supports memory + tools, NO structured output)
Memory Example (Step13):
AIAgent agent = chatClient.CreateAIAgent(new ChatClientAgentOptions()
{
Instructions = "You are a friendly assistant.",
AIContextProviderFactory = ctx => new UserInfoMemory(
chatClient.AsIChatClient(),
ctx.SerializedState,
ctx.JsonSerializerOptions)
});
// Only returns AgentRunResponse, not typed
AgentRunResponse response = await agent.RunAsync("Hello", thread);
Tools Example (Step03):
AIAgent agent = new AzureOpenAIClient(endpoint, credential)
.GetChatClient(deploymentName)
.CreateAIAgent(
instructions: "You are a helpful assistant",
tools: [AIFunctionFactory.Create(GetWeather)]);
// Only returns AgentRunResponse, not typed
AgentRunResponse response = await agent.RunAsync("What is the weather?");
ChatClientAgent (supports structured output, NO memory)
Structured Output Example (Step05):
ChatClientAgent agent = chatClient.CreateAIAgent(new ChatClientAgentOptions(
name: "HelpfulAssistant",
instructions: "You are a helpful assistant."));
// Returns typed response!
AgentRunResponse<PersonInfo> response = await agent.RunAsync<PersonInfo>(
"Please provide information about John Smith...");
PersonInfo person = response.Result; // Strongly typed access
The Gap
The framework provides no way to combine these capabilities:
- No
RunAsync<T>
extensions for AIAgent: The generic structured output methods only exist forChatClientAgent
- No memory support for ChatClientAgent:
ChatClientAgentOptions
has noAIContextProviderFactory
property - Forced choice: Developers must choose between memory/tools OR structured output
Expected Behavior
Developers should be able to write:
// This should work but currently doesn't:
AIAgent agent = chatClient.CreateAIAgent(new ChatClientAgentOptions()
{
Instructions = "You are a helpful assistant.",
AIContextProviderFactory = ctx => new UserInfoMemory(...), // Memory
ChatOptions = new() { Tools = [weatherTool] } // Tools
});
// This should exist but currently doesn't:
AgentRunResponse<PersonInfo> response = await agent.RunAsync<PersonInfo>(
"Extract person information...", thread); // Structured output
// Perfect: memory + tools + structured output in one agent!
PersonInfo person = response.Result;
Related Issues
- Issue Agent Abstraction Run Responses #86: Agent Abstraction Run Responses (discusses response structures)
- No existing issues found specifically addressing this API gap
Environment
- Microsoft Agent Framework: Latest (.NET)
- Platform: .NET 8+
- Package: Microsoft.Agents.AI
Repository Analysis
This issue is based on analysis of the official samples:
- Step03: Tools with AIAgent
- Step05: Structured Output with ChatClientAgent
- Step13: Memory with AIAgent
This limitation significantly impacts developer experience and prevents the framework from supporting common AI agent patterns. A unified interface would make the Microsoft Agent Framework more competitive with other agent frameworks that provide integrated memory, tools, and structured output capabilities.