Skip to content

Azure-Samples/sk-advanced-orchestration

Repository files navigation

Important

We are consolidating all Semantic Kernel advanced usage samples into a single repository. This repository will be archived in the future.

Semantic Kernel Advanced Customer Support

This repo showcases a sample AI-enabled customer support application that leverages Semantic Kernel Agents boosted with:

  • an improved SelectionStrategy that accounts for agents descriptions and available tools to provide a more accurate selection (including the reason for it for traceability).
  • nested orchestration via Teams and Agents for more complex, hierarchical routing scenarios.
  • a special type of Agent named PlannedTeam, which can handle more complex, cross-agent asks turning them into a multi-step process automatically.
  • improved telemetry and explainability via Application Insights to track agentic team steps and results, as well as the reasoning behind agent selection.

Additionally, the application leverages Azure Container Apps and Dapr to enable the Virtual Actor pattern for agentic teams and natively handle ChatHistory persistence via Dapr's state store, ensuring that the application can scale seamlessly.

Example

In this case, the user asks a question that requires the involvement of multiple agents, which are able to collaborate and produce a composite answer.

Example chat demonstrating agents producing a composite answer

Telemetry and explanability example

Waterfall chart of agentic team steps (Application Insights)

Exaple waterfall chart of agentic team steps and results

Additional debug information provided by the improved SelectionStrategy:

alt text

Azure AI Foundry tracing

See official documentation for more details.

alt text

Architecture

The overall architecture involves Dapr to enable the Virtual Actor pattern, in order to host the agentic team and natively handle ChatHistory persistence via Dapr's state store.

flowchart TD
  %% User and client
  U[User]
  CB[Browser / Client]
  U --> CB

  %% Container Apps (Dapr enabled)
  subgraph "Azure Container Apps"
    Chat["`Chat App<br/>(Dapr enabled)<br/>[src/chat]`"]
    Agents["`Agents App<br/>(Dapr enabled)<br/>[src/agents]`"]
  end

  CB --> Chat

  %% Dapr sidecars within container apps
  Chat -- "Dapr Sidecar" --> DS1["`Dapr: state store<br/>(in-memory / Cosmos DB)`"]
  Agents -- "Dapr Sidecar" --> DS2[Dapr Components]

  %% Communication Flow
  Chat --- Agents
  Agents --- Chat

  %% Azure Services and Infrastructure
  subgraph "Azure Resources"
    ACR["`Azure Container Registry<br/>[infra/acr.bicep]`"]
    AI["`Application Insights<br/>[infra/appin.bicep]`"]
    LA["`Log Analytics<br/>[infra/appin.bicep]`"]
    OAI["`Azure OpenAI<br/>[infra/openAI.bicep]`"]
    Cosmos["`Cosmos DB<br/>[infra/cosmos.bicep]`"]
    UAMI["`User Assigned Identity<br/>[infra/uami.bicep]`"]
  end

  %% Deployment orchestration via Azure Developer CLI
  ADCLI["`Azure Developer CLI<br/>(azd)`"]
  ADCLI --> ACR
  ADCLI --> AI
  ADCLI --> LA
  ADCLI --> OAI
  ADCLI --> Cosmos
  ADCLI --> UAMI

  %% Container App image source
  ACR --> Chat
  ACR --> Agents

  %% Monitoring and Telemetry
  Chat --> AI
  Agents --> AI
  AI --> LA

  %% Data persistence via Dapr state store
  DS1 --> Cosmos

  %% Semantic Kernel
  SK["`Semantic Kernel<br/>(LLM Processing)`"]
  Agents --> SK
  SK --- Agents
Loading

Getting Started

Prerequisites

Clone the repo

git clone https://github.com/Azure-Samples/mas-sk-quickstart
cd mas-sk-quickstart

Azure Deployment

Note

Script will NOT create a new Azure OpenAI resource. You will need to have an existing one with a deployed model.

# Login to Azure if required
azd auth login --tenant-id <TENANT>.onmicrosoft.com

azd up

# When prompted, select
# - Azure subscription to deploy to
# - Azure region to deploy to
# - EXISTING Azure OpenAI resource and group to use (azd will NOT create a new one)

Running Locally

Tip

If you deployed the application to Azure, you can run it locally using the same Azure resources. Simply copy the .env file from the .azure/<env name> folder to the root of the repo.

  1. cp .env.example .env
  2. Update .env with your Azure OpenAI resource endpoint.
  3. Ensure Docker is running.
  4. Init Dapr (once only): dapr init.
  5. Setup Python environment and install dependencies:
python -m venv .venv

# On macOS/Linux:
source .venv/bin/activate

# On Windows:
.venv\Scripts\Activate.ps1

pip install -r src/chat/requirements.txt
pip install -r src/agents/requirements.txt

To run:

dapr run -f dapr.yaml

Contributing

This project welcomes contributions and suggestions. Please see CONTRIBUTING.md for details.

License

This project is licensed under the MIT License. See LICENSE.md for details.

About

SK Multi agentic advanced orchestration example

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •