Workflow:Microsoft Semantic kernel Agent Conversation And Orchestration
| Knowledge Sources | |
|---|---|
| Domains | AI_Agents, Multi_Agent_Orchestration, LLMs |
| Last Updated | 2026-02-11 18:00 GMT |
Overview
End-to-end process for creating AI agents with the Semantic Kernel Agent Framework, equipping them with plugins, maintaining multi-turn conversations via threads, and orchestrating multiple agents through concurrent, sequential, group chat, and handoff patterns.
Description
This workflow covers the Semantic Kernel Agent Framework, which provides a higher-level abstraction over the kernel for building conversational AI agents. An agent wraps a kernel with persistent instructions, a name, and an identity. The framework supports multiple agent backends (ChatCompletionAgent, OpenAI Assistant, Azure AI, AWS Bedrock, Copilot Studio). The workflow progresses from single-agent conversations to multi-agent orchestration patterns including concurrent execution (same task to multiple specialists), sequential pipelines, round-robin group chats with termination conditions, and handoff routing (triage agent delegates to specialists).
Usage
Execute this workflow when you need conversational AI that goes beyond single-prompt interactions. Use it when you need agents that maintain conversation history across turns, agents equipped with domain-specific plugins, or multi-agent systems where specialized agents collaborate to solve complex tasks. Common use cases include customer support (triage and specialist handoff), content review (writer and reviewer agents), and parallel expert consultation.
Execution Steps
Step 1: Create a Chat Completion Agent
Instantiate a ChatCompletionAgent with a name, system instructions, and a configured kernel. The agent encapsulates the AI service and provides a conversational interface with built-in message management.
Key considerations:
- Name and Instructions define the agent's persona and behavior
- The agent requires a Kernel with at least one chat completion service registered
- Agents can also be created from YAML template definitions
- Alternative agent types exist for OpenAI Assistants, Azure AI, and Bedrock
Step 2: Equip Agent With Plugins
Add plugins to the agent's kernel to give it tool-calling capabilities. Plugins can be native C# classes, prompt functions, or OpenAPI-based APIs. Configure the function calling behavior to control whether the agent invokes tools automatically or requires approval.
Key considerations:
- Plugins are added via agent.Kernel.Plugins.Add()
- Function calling behavior (Auto, Manual, Required, None) controls invocation
- Function invocation filters can be added for logging and monitoring
- Prompt functions can be created inline using KernelFunctionFactory.CreateFromPrompt()
Step 3: Manage Conversation Threads
Create and maintain conversation threads to preserve context across multiple turns. A ChatHistoryAgentThread stores the message history in memory. Threads can be pre-populated with initial messages or built incrementally as the conversation progresses.
Key considerations:
- AgentThread is the abstract base; ChatHistoryAgentThread is the in-memory implementation
- Each agent.InvokeAsync() call returns a thread reference for continuation
- Threads can be pre-populated with seed messages for context
- Manually created threads allow injecting system messages or prior context
Step 4: Handle Single-Agent Conversations
Invoke the agent with user messages and an optional thread. The agent generates responses, updates the thread, and returns AgentResponseItems containing the assistant's reply. Continue the conversation by reusing the thread reference.
Key considerations:
- Single invocation without a thread creates a new ephemeral context
- Passing a thread enables multi-turn conversations
- Responses include ChatMessageContent with the agent's output
- The agent can return multiple messages in a single invocation (e.g., function calls + final response)
Step 5: Set Up Multi-Agent Orchestration
Choose an orchestration pattern based on the task structure. Create multiple specialized agents and wire them together using the appropriate orchestration class.
Orchestration patterns:
- Concurrent: Send the same input to multiple agents in parallel, collect all responses
- Sequential: Chain agents in a pipeline where each agent's output feeds the next
- Group Chat: Round-robin conversation between agents with a manager controlling termination
- Handoff: Triage agent routes to specialists based on user intent, specialists can transfer back
Key considerations:
- All orchestration patterns use InProcessRuntime for local execution
- ConcurrentOrchestration sends the same task to all agents simultaneously
- GroupChatOrchestration uses a manager (e.g., RoundRobinGroupChatManager) with termination logic
- HandoffOrchestration defines a routing graph with transfer conditions
Step 6: Configure Orchestration Runtime
Create an InProcessRuntime to host the orchestration. Start the runtime, invoke the orchestration with the initial input, and wait for results. The runtime manages agent lifecycle and message passing.
Key considerations:
- InProcessRuntime handles agent scheduling and communication
- Orchestration returns results via monitor callbacks
- Timeout can be set for result collection
- The runtime should be stopped after completion
Step 7: Collect and Process Results
Retrieve the orchestration output from the result monitor. For concurrent orchestration, collect all agent responses. For group chat, extract the final approved result. For handoff, the final agent's response is the output.
Key considerations:
- Monitor.History contains the full conversation log
- Custom termination conditions can be defined (e.g., "I Approve" in group chat)
- Filter functions can extract specific results from the history
- Streaming is supported for real-time response capture