Skip to content

.NET: Missing unified interface for AIAgent with memory, tools, and structured output #1412

@napgab

Description

@napgab

[.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:

  1. AIAgent: Supports memory (via AIContextProviderFactory) and tools, but lacks structured output (RunAsync<T>)
  2. 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:

  1. No RunAsync<T> extensions for AIAgent: The generic structured output methods only exist for ChatClientAgent
  2. No memory support for ChatClientAgent: ChatClientAgentOptions has no AIContextProviderFactory property
  3. 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

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:


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.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions