Version 1.0 (Semantic Kernel): Tagged as v1.0-semantic-kernel
Version 2.0 (Agent Framework): Target branch wip/bobjac/agent-framework-convert
Created: 2025-10-27
This document outlines the migration strategy from Microsoft Semantic Kernel v1.48.0 to Microsoft Agent Framework v1.0.0-preview for the Partnership Agent project. The Agent Framework is positioned as "Semantic Kernel v2.0" and represents the unified future for building AI agents at Microsoft.
- Current State: 1,500+ LOC using Semantic Kernel with advanced Process Framework (alpha)
- Target State: Microsoft Agent Framework (preview) with Workflows
- Risk Level: Medium-High (both frameworks have preview/alpha features)
- Timeline: Phased migration over multiple PRs
- Rollback Strategy: v1.0-semantic-kernel tag preserves stable baseline
User Request
↓
[WebApi/ConsoleApp]
↓
StepOrchestrationService
↓
ProcessBuilder → KernelProcess (5 Steps, Event-Driven)
↓
┌────────────────────────────────────────────────┐
│ ScopingStep → EntityResolutionStep │
│ ↓ ↓ │
│ DocumentSearchStep → ResponseGenerationStep │
│ ↓ │
│ UserResponseStep │
└────────────────────────────────────────────────┘
↓
3 Specialized ChatCompletionAgents:
- ScopingAgent (scope validation)
- EntityResolutionAgent (entity extraction)
- FAQAgent (document search + answer generation)
User Request
↓
[WebApi/ConsoleApp]
↓
WorkflowOrchestrationService
↓
WorkflowBuilder → Workflow<ChatMessage> (Edge-Based Graph)
↓
┌──────────────────────────────────────────────┐
│ ScopingAgent → EntityResolutionAgent │
│ ↓ ↓ │
│ DocumentSearchAgent → ResponseGenerationAgent│
│ ↓ │
│ UserResponseAgent │
└──────────────────────────────────────────────┘
↓
5 ChatClientAgent instances:
- ScopingAgent (scope validation)
- EntityResolutionAgent (entity extraction)
- DocumentSearchAgent (document retrieval)
- ResponseGenerationAgent (answer generation)
- UserResponseAgent (final delivery)
Key Architectural Change: Event-driven steps → Graph edges with direct agent connections
| Current Component | SK Type | Target Component | AF Type | Migration Complexity |
|---|---|---|---|---|
| BaseChatHistoryAgent | Abstract base extending ChatHistoryAgent | BaseAgent | Abstract wrapper around ChatClientAgent | Medium (refactor base class) |
| ScopingAgent | ChatCompletionAgent | ScopingAgent | ChatClientAgent | Low (mostly config) |
| EntityResolutionAgent | ChatCompletionAgent | EntityResolutionAgent | ChatClientAgent | Low (mostly config) |
| FAQAgent | ChatCompletionAgent | DocumentSearchAgent + ResponseGenerationAgent | Two ChatClientAgent instances | Medium (split responsibilities) |
| StepOrchestrationService | ProcessBuilder orchestration | WorkflowOrchestrationService | WorkflowBuilder orchestration | High (paradigm shift) |
| ScopingStep | KernelProcessStep | Workflow edge + ScopingAgent | Agent in graph | Medium (convert step logic) |
| EntityResolutionStep | KernelProcessStep | Workflow edge + EntityResolutionAgent | Agent in graph | Medium (convert step logic) |
| DocumentSearchStep | KernelProcessStep | Workflow edge + DocumentSearchAgent | Agent in graph | Medium (convert step logic) |
| ResponseGenerationStep | KernelProcessStep | Workflow edge + ResponseGenerationAgent | Agent in graph | Medium (convert step logic) |
| UserResponseStep | KernelProcessStep | Workflow edge + UserResponseAgent | Agent in graph | Low (terminal step) |
| Kernel | Core orchestrator | Removed | N/A (agents self-contained) | High (remove all Kernel references) |
| KernelFunction decorator | [KernelFunction] attribute |
AIFunctionFactory | Direct function creation | Low (minimal changes) |
| InvokeAsync/InvokeStreamingAsync | Agent invocation | RunAsync/RunStreamingAsync | Agent invocation | Low (rename + signature change) |
| KernelProcessEvent | Event emission | Workflow edges | Graph routing | High (conceptual change) |
| ChatHistory | Manual management | AgentThread | Auto-managed by agent | Medium (simplification) |
| OpenAIPromptExecutionSettings | Complex nested config | ChatClientAgentRunOptions | Simplified config | Low (flatten config) |
Goal: Set up Agent Framework dependencies and create basic agent infrastructure
Tasks:
- ✅ Create migration branch
wip/bobjac/agent-framework-convert - ✅ Tag v1.0 as
v1.0-semantic-kernel - Add Agent Framework NuGet packages:
<PackageReference Include="Microsoft.Agents.AI" Version="1.0.0-preview.251016.1" /> <PackageReference Include="Microsoft.Agents.AI.Workflows" Version="1.0.0-preview.251016.1" /> <PackageReference Include="Microsoft.Extensions.AI" Version="9.10.0" /> <PackageReference Include="Microsoft.Extensions.AI.OpenAI" Version="9.10.0" />
- Create new
BaseAgentwrapper class (Agent Framework equivalent ofBaseChatHistoryAgent) - Update DI configuration in
Program.csto support both patterns (temporary)
Acceptance Criteria:
- Solution builds successfully with Agent Framework packages
- No breaking changes to existing SK code (parallel setup)
BaseAgentclass created with proper abstractions
Risk: Low - Additive changes only
Goal: Migrate 3 ChatCompletionAgents → ChatClientAgent pattern
Complexity: Low
Changes:
// BEFORE (SK)
public class ScopingAgent : BaseChatHistoryAgent
{
Agent = new ChatCompletionAgent
{
Instructions = scopingInstructions,
Kernel = kernel,
Arguments = new KernelArguments(executionSettings)
};
[KernelFunction]
public async Task<ScopingAgentResponse> DetermineScope(string prompt) { ... }
}
// AFTER (AF)
public class ScopingAgent : BaseAgent
{
Agent = chatClient.CreateAIAgent(
name: "ScopingAgent",
instructions: scopingInstructions,
tools: [AIFunctionFactory.Create(DetermineScope)]
);
public async Task<ScopingAgentResponse> DetermineScope(
[Description("User's request to evaluate")] string prompt) { ... }
}Tasks:
- Remove
Kerneldependency from ScopingAgent - Replace
ChatCompletionAgentwithChatClientAgentviaCreateAIAgent() - Convert
[KernelFunction]toAIFunctionFactory.Create() - Update
InvokeAsync()→RunAsync()pattern - Update unit tests for ScopingAgent
- Create integration test comparing v1 vs v2 outputs
Acceptance Criteria:
- ScopingAgent works identically with Agent Framework
- All unit tests pass
- Integration test shows equivalent responses
Complexity: Low
Tasks: (Same pattern as ScopingAgent)
- Remove Kernel dependency
- Replace ChatCompletionAgent with ChatClientAgent
- Convert function decorators
- Update invocation methods
- Update tests
Complexity: Medium-High
Changes: Split FAQAgent into two focused agents:
// NEW: DocumentSearchAgent
public class DocumentSearchAgent : BaseAgent
{
// Responsibilities:
// - SearchDocuments kernel function
// - ElasticSearch/AzureVectorSearch integration
// - Returns List<DocumentResult>
}
// NEW: ResponseGenerationAgent
public class ResponseGenerationAgent : BaseAgent
{
// Responsibilities:
// - GenerateAnswer function
// - Citation formatting
// - Streaming support via IBidirectionalToClientChannel
// - Response evaluation
}Rationale:
- Current FAQAgent has 2 kernel functions (search + generation) → better as separate agents
- Aligns with Agent Framework's "single responsibility" agent pattern
- Enables better workflow orchestration
Tasks:
- Create
DocumentSearchAgentwith search capabilities - Create
ResponseGenerationAgentwith answer generation - Migrate
SearchDocuments()function to DocumentSearchAgent - Migrate
GenerateAnswer()function to ResponseGenerationAgent - Update ChatHistoryService integration
- Update tests for both new agents
Acceptance Criteria:
- DocumentSearchAgent successfully retrieves documents
- ResponseGenerationAgent produces equivalent answers
- Streaming still works with IBidirectionalToClientChannel
- Citations maintain same quality
Goal: Replace KernelProcess event-driven orchestration with WorkflowBuilder graph
Complexity: High - This is the most complex migration step
ProcessBuilder processBuilder = new("PartnershipAgent");
var scopingStep = processBuilder.AddStepFromType<ScopingStep>();
// ... add all steps ...
processBuilder
.OnInputEvent(AgentOrchestrationEvents.StartProcess)
.SendEventTo(new ProcessFunctionTargetBuilder(scopingStep));
scopingStep
.OnEvent(AgentOrchestrationEvents.ScopingCompleted)
.SendEventTo(new ProcessFunctionTargetBuilder(entityResolutionStep));
// Complex event routing with early termination support// Create agents
var scopingAgent = CreateScopingAgent();
var entityAgent = CreateEntityResolutionAgent();
var searchAgent = CreateDocumentSearchAgent();
var responseAgent = CreateResponseGenerationAgent();
var userResponseAgent = CreateUserResponseAgent();
// Build workflow with edges
WorkflowBuilder builder = new(scopingAgent);
// Add edges to connect agents
builder.AddEdge(scopingAgent, entityAgent,
condition: (msg) => msg.IsInScope); // Conditional routing
builder.AddEdge(scopingAgent, userResponseAgent,
condition: (msg) => !msg.IsInScope); // Out-of-scope short-circuit
builder.AddEdge(entityAgent, searchAgent);
builder.AddEdge(searchAgent, responseAgent,
condition: (msg) => msg.DocumentsFound);
builder.AddEdge(searchAgent, userResponseAgent,
condition: (msg) => !msg.DocumentsFound); // Clarification needed
builder.AddEdge(responseAgent, userResponseAgent);
Workflow<ChatMessage> workflow = builder.Build<ChatMessage>();Migration Tasks:
-
Create WorkflowOrchestrationService:
- Replace
StepOrchestrationService - Implement
WorkflowBuildersetup - Define all agent connections via edges
- Replace
-
Implement Conditional Routing:
- Map event types to edge conditions
- Handle early termination (out-of-scope, no documents)
- Maintain equivalent flow logic
-
State Management:
- Replace
ProcessModelwith workflow state - Use
context.ReadStateAsync()andcontext.WriteStateAsync() - Ensure data flows correctly between agents
- Replace
-
Streaming Support:
- Integrate
IBidirectionalToClientChannelwith workflow - Handle
AgentRunUpdateEventfor streaming chunks - Maintain real-time client communication
- Integrate
-
Error Handling:
- Replace
ProcessErrorevents with workflow error handling - Implement try-catch around workflow execution
- Graceful degradation for partial failures
- Replace
-
Remove Step Classes:
- Delete
BaseKernelProcessStep.cs - Delete all 5 step implementations (ScopingStep, EntityResolutionStep, etc.)
- Move any step-specific logic into agents or orchestration service
- Delete
Acceptance Criteria:
- Workflow executes agents in correct order
- Conditional routing works (out-of-scope, no documents, etc.)
- State passes between agents correctly
- Streaming maintains real-time performance
- Error handling covers all scenarios
- End-to-end integration tests pass
Goal: Update DI container and configuration for Agent Framework
Changes to Program.cs:
// BEFORE (SK)
builder.Services.AddScoped<IKernelBuilder>(provider =>
{
var kernelBuilder = Kernel.CreateBuilder();
kernelBuilder.AddAzureOpenAIChatCompletion(...);
return kernelBuilder;
});
builder.Services.AddScoped<ScopingAgent>(provider =>
{
var kernelBuilder = provider.GetRequiredService<IKernelBuilder>();
return new ScopingAgent(Guid.NewGuid(), kernelBuilder, ...);
});
// AFTER (AF)
builder.Services.AddSingleton<IChatClient>(provider =>
{
var azureClient = new AzureOpenAIClient(new Uri(endpoint), new ApiKeyCredential(apiKey));
return azureClient.GetChatClient(deploymentName);
});
builder.Services.AddScoped<ScopingAgent>(provider =>
{
var chatClient = provider.GetRequiredService<IChatClient>();
return new ScopingAgent(chatClient, ...);
});
builder.Services.AddScoped<WorkflowOrchestrationService>();Tasks:
- Remove
IKernelBuilderregistration - Add
IChatClientregistration with Azure OpenAI - Update all agent registrations to use IChatClient
- Update
WorkflowOrchestrationServiceregistration - Remove step registrations (no longer needed)
- Update configuration validation
Acceptance Criteria:
- DI container resolves all agents correctly
- ChatClient properly configured with Azure OpenAI
- No Kernel dependencies remain
Goal: Comprehensive testing to ensure migration maintains functionality
Test Strategy:
-
Unit Tests:
- Update all agent unit tests for new API patterns
- Test workflow routing logic
- Test conditional edge execution
- Test error handling
-
Integration Tests:
- Create side-by-side tests comparing v1 (SK) vs v2 (AF) outputs
- Test full workflow execution end-to-end
- Test streaming responses
- Test all routing paths (in-scope, out-of-scope, no documents, etc.)
-
Performance Tests:
- Compare response times SK vs AF
- Measure streaming latency
- Load testing (if applicable)
-
Manual Testing:
- Test via WebAPI endpoints
- Test via ConsoleApp
- Verify OpenTelemetry traces still work
- Verify chat history persistence (SQLite, Azure SQL)
Acceptance Criteria:
- All unit tests pass (100% coverage maintained)
- Integration tests show equivalent or better results
- No performance regressions
- All user-facing features work identically
Goal: Update documentation and remove SK remnants
Tasks:
- Update README.md with Agent Framework references
- Update architecture documentation
- Update evaluation documentation (if affected)
- Remove all SK packages from .csproj files
- Remove SK-specific code comments
- Update API documentation
- Update setup scripts if needed
- Create CHANGELOG.md entry for v2.0
Acceptance Criteria:
- Documentation reflects Agent Framework architecture
- No SK references remain in docs
- Setup/installation instructions updated
- Changelog documents all breaking changes
| Risk | Impact | Probability | Mitigation |
|---|---|---|---|
| Agent Framework API changes during migration | High | Medium | Monitor GitHub releases; pin to specific preview version |
| Workflow orchestration doesn't support all SK Process features | High | Medium | Prototype complex routing early; file issues with Microsoft if needed |
| Performance regression in streaming | Medium | Low | Performance tests in Phase 5; optimize before merging |
| Breaking changes in Agent Framework before GA | High | High | Stay on v1 until AF reaches GA; delay production deployment |
| Risk | Impact | Probability | Mitigation |
|---|---|---|---|
| Chat history integration issues | Medium | Low | Test early with all backends (InMemory, SQLite, Azure SQL) |
| OpenTelemetry tracing gaps | Medium | Low | Verify telemetry in Phase 5; add custom instrumentation if needed |
| Tool/function calling behavior differences | Medium | Medium | Integration tests comparing function execution |
| Risk | Impact | Probability | Mitigation |
|---|---|---|---|
| Agent instructions require tuning | Low | Medium | A/B test with evaluation framework |
| DI container configuration issues | Low | Low | Unit tests for service resolution |
-
Immediate Rollback:
git checkout main git branch -D wip/bobjac/agent-framework-convert git checkout v1.0-semantic-kernel -b wip/bobjac/agent-framework-convert # Resume from stable baseline -
Partial Rollback:
- Each phase is a separate PR (if desired)
- Can revert specific commits while keeping others
-
Production Strategy:
- Keep v1 (SK) in production until v2 (AF) fully validated
- Run both versions in parallel during transition
- Use feature flags to toggle between implementations
- ✅ All agents migrate to ChatClientAgent
- ✅ Workflow orchestration replaces Process Framework
- ✅ All unit tests pass
- ✅ Integration tests show equivalent functionality
- ✅ No Semantic Kernel dependencies remain
- ✅ Streaming works correctly
- Performance improvements over SK
- Simplified codebase (fewer LOC)
- Better observability via AF tooling
- Workflow debugging in DevUI
| Phase | Duration | Status | Complexity |
|---|---|---|---|
| Phase 1: Foundation & Setup | Week 1 | 🟢 Ready | Low |
| Phase 2: Agent Migration | Week 2-3 | 🟡 Planned | Low-Medium |
| Phase 3: Workflow Migration | Week 4-5 | 🔴 High Risk | High |
| Phase 4: DI & Configuration | Week 6 | 🟡 Planned | Medium |
| Phase 5: Testing & Validation | Week 7 | 🟡 Planned | Medium |
| Phase 6: Documentation & Cleanup | Week 8 | 🟢 Ready | Low |
Total Estimated Duration: 8 weeks (phased, part-time) Critical Path: Phase 3 (Workflow Migration)
- ✅ Split FAQAgent into DocumentSearchAgent + ResponseGenerationAgent
- ✅ Use WorkflowBuilder with edge-based routing (not events)
- ✅ Maintain v1 tag for rollback safety
- ✅ Phased migration over single big-bang rewrite
- ❓ Should we wait for Agent Framework GA before production deployment?
- ❓ Do we need custom workflow executors or are agents sufficient?
- ❓ How to handle evaluation framework integration with AF?
- ❓ Should we maintain both v1 and v2 branches long-term or merge after validation?
- Partnership Agent v1 Architecture (from exploration analysis)
- Semantic Kernel Process Framework docs
- Chat History Service documentation
Immediate Actions:
- Review this migration plan with stakeholders
- Decide on GA vs Preview deployment strategy
- Begin Phase 1: Foundation & Setup
- Create tracking issues for each phase
Before Starting Phase 3:
- Prototype workflow routing with minimal example
- Validate conditional edge logic works as expected
- Confirm state management pattern
Document Version: 1.0 Last Updated: 2025-10-27 Owner: Partnership Agent Team Status: 📋 Ready for Review