A collection of C# projects demonstrating various capabilities of the Microsoft Agent Framework (preview). This repository serves as a learning resource and playground for exploring AI agent patterns, workflows, structured output, RAG, and more.
This repository contains multiple independent projects, each showcasing different aspects of the Microsoft Agent Framework:
- Basic agent creation with function calling
- Structured output extraction from unstructured text
- Thread persistence for conversational continuity
- RAG (Retrieval-Augmented Generation) with vector search
- Workflows for orchestrating multi-step agent processes
- Foundry integration for managed agents
- Semantic Kernel integration examples
Basic agent with function calling
Demonstrates:
- Creating a simple AI agent using
ChatClient.CreateAIAgent() - Function calling with
AIFunctionFactory.Create() - Streaming responses
- Basic agent-thread interaction
Key concepts:
AIAgentandAgentThread- Tool/function integration
- Streaming responses
Structured output extraction
Demonstrates:
- Extracting structured data from unstructured text (meeting transcripts)
- Using
RunAsync<T>()for type-safe structured output - JSON schema generation from C# classes
Key concepts:
- Structured output with
Descriptionattributes - Type-safe LLM responses
- JSON schema generation
Conversation persistence
Demonstrates:
- Saving and loading agent threads
- Resuming conversations across sessions
- Custom thread and message storage (
FileThreadStore,FileChatMessageStore)
Key concepts:
- Thread serialization/deserialization
- Conversation continuity
- Custom storage providers
Azure AI Foundry integration
Demonstrates:
- Using Azure AI Foundry's managed agents
PersistentAgentsClientfor agent lifecycle management- Creating and retrieving agents from Foundry
Key concepts:
- Managed agents in Azure AI Foundry
- Agent persistence in the cloud
- Azure authentication (
AzureCliCredential)
Retrieval-Augmented Generation
Demonstrates:
- Vector store integration (In-Memory)
- Embedding generation with Azure OpenAI
TextSearchProviderfor on-demand RAG- Knowledge base creation and search
Key concepts:
- Vector embeddings and similarity search
- RAG pattern with
TextSearchProvider - Context injection into agent prompts
Multi-step workflow orchestration
Demonstrates:
- Building complex workflows with multiple executors
- Combining LLM agents with deterministic logic
- Conditional routing based on context
- Shared state management
- Custom events for observability
Workflow example: Customer support email triage and response
- Preprocess (deterministic): Clean text, detect/mask PII, extract identifiers
- Intake (LLM agent): Classify category, urgency, sentiment, intent
- Policy (deterministic): Apply business rules, determine response mode
- Route (conditional): Escalate, refund automation, or draft reply
- Final Summary (deterministic): Consolidate output from shared state
Key concepts:
WorkflowBuilderandExecutor<TInput, TOutput>- Conditional edges (
AddEdge<T>(..., condition: ...)) - Shared state (
QueueStateUpdateAsync,ReadStateAsync) - Custom events for tracing
- Hybrid executors (agent + deterministic)
See AgentFrameworkWorkflows/workflow.md for a visual diagram.
Semantic Kernel integration examples
Demonstrates integration patterns between Semantic Kernel and Agent Framework.
- .NET 10.0 SDK or later
- Azure OpenAI account with:
- API endpoint
- API key
- Model deployment (e.g.,
gpt-4,gpt-35-turbo) - Embedding model deployment (for RAG project)
Most projects require an appsettings.json or appsettings.Development.json file with:
{
"ModelName": "your-model-deployment-name",
"Endpoint": "https://your-resource.openai.azure.com/",
"ApiKey": "your-api-key",
"EmbeddingModel": "your-embedding-model-name" // For RAG project
}Some projects (Foundry) may require additional configuration:
{
"ProjectEndpoint": "https://your-project.cognitiveservices.azure.com/"
}Each project is a standalone console application. Run from the project directory:
cd AgentFramework
dotnet runOr run from the solution root:
dotnet run --project AgentFramework/1-AgentFramework.csprojAgentFrameworkPlayground/
├── AgentFramework/ # Basic agent example
├── AgentFrameworkStructuredOutput/ # Structured output
├── AgentFrameworkThreadPersistancy/ # Thread persistence
├── AgentFrameworkFoundryAgent/ # Foundry integration
├── AgentFrameworkRag/ # RAG example
├── AgentFrameworkWorkflows/ # Workflow orchestration
│ ├── Executors/ # Workflow executors
│ ├── Models/ # Data models
│ ├── Events/ # Custom events
│ └── workflow.md # Workflow diagram
├── Common/ # Shared utilities
├── SemanticKernel/ # SK examples
└── SemanticKernelAgentFramework/ # SK + Agent Framework
- AIAgent: Core agent abstraction
- ChatClientAgent: Chat-based agent implementation
- AgentThread: Conversation context management
- Executor: Individual processing units in a workflow
- WorkflowBuilder: Fluent API for building workflow graphs
- Conditional Edges: Dynamic routing based on message content
- Shared State: Cross-executor data sharing
- Events: Observability and tracing
- Hybrid Executors: Combining LLM agents with deterministic logic
- Structured Output: Type-safe LLM responses
- RAG: Context injection via vector search
- Persistence: Thread and message storage
All projects include #pragma warning disable directives for preview API warnings.
This is a learning/playground repository. Check individual project licenses if applicable.