AgentSdk 0.1.0-alpha.4
dotnet add package AgentSdk --version 0.1.0-alpha.4
NuGet\Install-Package AgentSdk -Version 0.1.0-alpha.4
<PackageReference Include="AgentSdk" Version="0.1.0-alpha.4" />
<PackageVersion Include="AgentSdk" Version="0.1.0-alpha.4" />
<PackageReference Include="AgentSdk" />
paket add AgentSdk --version 0.1.0-alpha.4
#r "nuget: AgentSdk, 0.1.0-alpha.4"
#:package AgentSdk@0.1.0-alpha.4
#addin nuget:?package=AgentSdk&version=0.1.0-alpha.4&prerelease
#tool nuget:?package=AgentSdk&version=0.1.0-alpha.4&prerelease
Cyclotron.Maf.AgentSdk
A .NET SDK for building AI agent workflows using Microsoft Agent Framework (MAF) and Azure AI Foundry. Provides workflow orchestration, agent factories, vector store management, PDF processing, and OpenTelemetry integration.
Features
- Workflow Orchestration - Build sequential executor pipelines using MAF's
Executor<TInput, TOutput>pattern - Agent Factory - Create and manage ephemeral Azure AI Foundry agents with keyed DI support
- Vector Store Management - Lifecycle management for Azure AI Foundry vector stores with automatic indexing wait
- PDF Processing - Convert PDF documents to markdown using PdfPig for better text extraction
- Prompt Rendering - Handlebars-based template rendering for dynamic agent prompts
- OpenTelemetry - Built-in tracing, metrics, and logging with OTLP exporter support
- Configurable Tools - Enable
file_searchand/orcode_interpretervia YAML configuration
Installation
dotnet add package Cyclotron.Maf.AgentSdk
Quick Start
1. Configure Services
using Cyclotron.Maf.AgentSdk.Agents;
using Cyclotron.Maf.AgentSdk.Services;
using Microsoft.Extensions.DependencyInjection;
var builder = Host.CreateApplicationBuilder(args);
// Load agent configuration from agent.config.yaml and .env files
builder.UseAgentSdk();
// Register core services
builder.Services.AddAgentSdkServices();
// Add telemetry (optional)
builder.AddAgentSdkTelemetry();
2. Define Agent Configuration
Create agent.config.yaml in your project:
# Model Provider Configuration
providers:
azure_foundry:
type: "azure_foundry"
endpoint: "${PROJECT_ENDPOINT}" # Environment variable substitution
deployment_name: "${PROJECT_DEPLOYMENT_NAME}"
api_version: "2024-12-01-preview"
timeout_seconds: 300
max_retries: 3
# Agent Configuration
agents:
my_agent:
type: "custom"
enabled: true
auto_delete: true # Delete agent after workflow completes
auto_cleanup_resources: true # Delete vector store after workflow completes
metadata:
description: "Document processing agent"
tools: # Configure which tools the agent can use
- "file_search" # Enable document search in vector stores
- "code_interpreter" # Enable Python code execution (optional)
framework_config:
provider: "azure_foundry" # Reference to providers section
system_prompt_template: |
You are a helpful assistant specialized in document analysis.
user_prompt_template: |
Process the document: {{fileName}}
Context: {{context}}
3. Set Environment Variables
Create a .env file in your project root:
PROJECT_ENDPOINT=https://your-project.api.azureml.ms
PROJECT_DEPLOYMENT_NAME=gpt-4o
4. Create Workflow Executors
using Cyclotron.Maf.AgentSdk.Agents;
using Microsoft.Agents.AI.Workflows.Executors;
using Microsoft.Extensions.DependencyInjection;
public class MyProcessingExecutor : Executor<InputType, OutputType>
{
private readonly IAgentFactory _agentFactory;
public MyProcessingExecutor(
[FromKeyedServices("my_agent")] IAgentFactory agentFactory)
{
_agentFactory = agentFactory;
}
public override async ValueTask<OutputType> HandleAsync(
InputType input,
IWorkflowContext context,
CancellationToken cancellationToken = default)
{
// Create agent with vector store
await _agentFactory.CreateAgentAsync(vectorStoreId, cancellationToken);
try
{
// Run agent with automatic retry and polling
var response = await _agentFactory.RunAgentWithPollingAsync(
messages: [_agentFactory.CreateUserMessage(promptContext)],
cancellationToken: cancellationToken);
// Process response...
return result;
}
finally
{
// Cleanup respects auto_delete and auto_cleanup_resources settings
await _agentFactory.CleanupAsync(cancellationToken);
}
}
}
5. Build and Execute Workflow
using Microsoft.Agents.AI.Workflows;
var workflow = new WorkflowBuilder(executor1)
.AddEdge(executor1, executor2)
.AddEdge(executor2, executor3)
.WithOutputFrom(executor3)
.Build();
var result = await workflow.ExecuteAsync<OutputType>(input, cancellationToken);
Configuration Reference
Agent Configuration (agent.config.yaml)
Provider Options
| Property | Type | Description | Default |
|---|---|---|---|
type |
string | Provider type (azure_foundry) |
Required |
endpoint |
string | Azure AI Foundry endpoint URL | Required |
deployment_name |
string | Model deployment name | Required |
model |
string | Alternative to deployment_name | - |
api_version |
string | API version | 2024-12-01-preview |
timeout_seconds |
int | Request timeout | 300 |
max_retries |
int | Maximum retry attempts | 3 |
Agent Definition Options
| Property | Type | Description | Default |
|---|---|---|---|
type |
string | Agent type identifier | Required |
enabled |
bool | Whether agent is active | true |
auto_delete |
bool | Delete agent/thread after use | true |
auto_cleanup_resources |
bool | Delete vector store after use | false |
system_prompt_template |
string | Handlebars template for system prompt | - |
user_prompt_template |
string | Handlebars template for user prompt | - |
Agent Metadata Options
| Property | Type | Description | Default |
|---|---|---|---|
description |
string | Human-readable description | "" |
tools |
string[] | Tools to enable: file_search, code_interpreter |
[] |
Note: If no tools are configured,
file_searchis enabled by default when creating an agent with a vector store.
Framework Config Options
| Property | Type | Description | Default |
|---|---|---|---|
provider |
string | Reference to a provider in the providers section |
Required |
Environment Variables
Values in agent.config.yaml support ${VAR_NAME} syntax for environment variable substitution:
endpoint: "${PROJECT_ENDPOINT}" # Reads PROJECT_ENDPOINT from environment
deployment_name: "${PROJECT_DEPLOYMENT_NAME}"
Application Settings (appsettings.json)
Telemetry Options
{
"Telemetry": {
"Enabled": true,
"SourceName": "MyAgentService",
"EnableSensitiveData": false,
"OtlpEndpoint": "http://localhost:4318"
}
}
Vector Store Indexing Options
{
"VectorStoreIndexing": {
"MaxWaitAttempts": 60,
"InitialWaitDelayMs": 2000,
"UseExponentialBackoff": true,
"MaxWaitDelayMs": 30000
}
}
PDF Conversion Options
{
"PdfConversion": {
"Enabled": true,
"SaveMarkdownForDebug": false,
"OutputDirectory": "./output"
}
}
Namespaces
| Namespace | Description |
|---|---|
Cyclotron.Maf.AgentSdk |
Root namespace |
Cyclotron.Maf.AgentSdk.Agents |
Agent factory and related types |
Cyclotron.Maf.AgentSdk.Models |
Data models and DTOs |
Cyclotron.Maf.AgentSdk.Models.Workflow |
Workflow-specific models |
Cyclotron.Maf.AgentSdk.Options |
Configuration options classes |
Cyclotron.Maf.AgentSdk.Services |
Service interfaces |
Cyclotron.Maf.AgentSdk.Services.Impl |
Service implementations |
Cyclotron.Maf.AgentSdk.Workflows |
Workflow executors |
Key Interfaces
| Interface | Description |
|---|---|
IAgentFactory |
Creates and manages Azure AI Foundry agents |
IVectorStoreManager |
Manages vector store lifecycle |
IPdfToMarkdownConverter |
Converts PDF documents to markdown |
IPromptRenderingService |
Renders Handlebars templates |
IPersistentAgentsClientFactory |
Creates Azure AI Foundry clients |
IAzureFoundryCleanupService |
Cleans up Azure AI Foundry resources |
Workflow State Management
Use WorkflowStateConstants for common state keys:
using Cyclotron.Maf.AgentSdk.Models.Workflow;
// Define your domain-specific scope constants
public static class MyWorkflowStateConstants
{
public static readonly string MyDataScope = nameof(MyDataScope);
}
// Store data in workflow state
await context.QueueStateUpdateAsync(
MyWorkflowStateConstants.MyDataScope,
data,
scopeName: WorkflowStateConstants.GetScopeName(workflowId, MyWorkflowStateConstants.MyDataScope),
cancellationToken);
// Read data from workflow state
var data = await context.ReadStateAsync<MyType>(
MyWorkflowStateConstants.MyDataScope,
scopeName: WorkflowStateConstants.GetScopeName(workflowId, MyWorkflowStateConstants.MyDataScope),
cancellationToken);
Dependencies
| Package | Version |
|---|---|
| Azure.AI.Agents.Persistent | 1.2.0-beta.7 |
| Azure.AI.OpenAI | 2.5.0-beta.1 |
| Azure.Identity | 1.17.0 |
| Microsoft.Agents.AI.Workflows | 1.0.0-preview.251114.1 |
| Microsoft.Agents.AI.AzureAI | 1.0.0-preview.251114.1 |
| Microsoft.Extensions.AI | 10.0.0 |
| OpenTelemetry | 1.9.0 |
| PdfPig | 0.1.12 |
| Handlebars.Net | 2.1.6 |
| Polly.Core | 8.5.0 |
Requirements
- .NET 8.0 or later
- Azure AI Foundry project endpoint
- Azure credentials (DefaultAzureCredential or API key)
Samples
See the SpamDetection sample for a complete working example.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Azure.AI.Agents.Persistent (>= 1.2.0-beta.7)
- Azure.AI.OpenAI (>= 2.5.0-beta.1)
- Azure.Identity (>= 1.17.0)
- Azure.Monitor.OpenTelemetry.Exporter (>= 1.3.0)
- DotNetEnv (>= 3.1.1)
- Handlebars.Net (>= 2.1.6)
- Microsoft.Agents.AI.AzureAI (>= 1.0.0-preview.251114.1)
- Microsoft.Agents.AI.AzureAI.Persistent (>= 1.0.0-preview.251114.1)
- Microsoft.Agents.AI.OpenAI (>= 1.0.0-preview.251114.1)
- Microsoft.Agents.AI.Workflows (>= 1.0.0-preview.251114.1)
- Microsoft.Extensions.AI (>= 10.0.0)
- Microsoft.Extensions.AI.OpenAI (>= 10.0.0-preview.1.25560.10)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging (>= 10.0.0)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- NetEscapades.Configuration.Yaml (>= 3.1.0)
- OpenTelemetry (>= 1.14.0)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.14.0)
- OpenTelemetry.Extensions.Hosting (>= 1.14.0)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.14.0)
- OpenTelemetry.Instrumentation.Http (>= 1.14.0)
- OpenTelemetry.Instrumentation.Runtime (>= 1.14.0)
- PdfPig (>= 0.1.12)
- Polly.Core (>= 8.5.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-alpha.4 | 133 | 11/26/2025 |