
semantic-kernel
AIエージェントを組み立てるためのSDK。作り込みは厚いものの、新機能の開発は後継のAgent Frameworkへ移っています。
semantic-kernelとは
手元のクラスのメソッドにカーネル関数の目印を付け、プラグインとしてまとめてカーネルに登録する——この流れが中心にあり、カーネルにはモデルへの接続も一緒に入るので、OpenAIからAzure OpenAIやOllamaへ移すときに書き換えるのは登録部分だけで済みます。OpenAPIの定義があれば社内の既存APIをそのまま道具にでき、フィルターという仕組みで呼び出しの前後に記録や伏せ字を挟むこともできます。弱点は品質ではなく方向性で、Microsoftは新機能の大半を後継のAgent Frameworkで作ると明言しているため、これから新規に始める案件よりも、すでにこのSDKで書かれた資産を保守し育てていく現場に向いています。
semantic-kernelで何ができますか?
- モデルへの接続も道具もカーネル一箇所に登録する — カーネルはモデルへの接続とプラグインを入れておく器で、組み立てたエージェントはそこから必要なものを取り出します。OpenAIからAzure OpenAI、Ollama、Hugging Faceへ乗り換えるときに書き換えるのは登録部分だけで、エージェント側のコードには触れずに済みます。
- 手元のメソッドをカーネル関数にすればモデルの道具になる — クラスのメソッドにカーネル関数の目印——C#なら属性、Pythonならデコレーター——を付けると、関数名と説明、引数の型がそのままモデルへ渡す道具の説明になります。既存のAPIはOpenAPIの定義から丸ごとプラグインにでき、MCPサーバーからの取り込みと、自分の関数をMCPサーバーとして公開するやり方はPython向けにだけ文書化されていて、.NET向けにはリポジトリのサンプルが置かれています。
- モデルの動きに割り込める地点が三つある — プロンプトを組み立てる直前、カーネル関数を呼ぶ前後、自動での道具呼び出しの最中——この三つに自分の処理を差し込めます。公式文書では個人情報の伏せ字、応答のキャッシュ、別モデルでの再試行、答えが出た時点での打ち切りが用途として挙がっています。フィルターはカーネルに付く仕組みなので、カーネルを渡さずにチャット用のサービスを直接呼ぶと働きません。
- 複数エージェントの協調に五つの型が用意されている — Concurrent(全員に同じ仕事を配って結果を集める)、Sequential(前の結果を次へ渡す)、Handoff(文脈に応じて担当を移す)、Group Chat(進行役のもとで全員が会話する)、Magentic(Group Chatを広い課題向けに拡張したもの)の五つです。どれも同じ書き方で組み立てて実行できるため、協調のしかたを変えてもエージェント自体は書き直さずに済みます。
- 会話の履歴を手元に置くかサービスに預けるか選べる — スレッドという単位で一つの会話の状態を持ちます。自分のプロセス内に抱える方式のほか、MicrosoftのFoundryプロジェクト上で動くAzure AI Agent Serviceのように、サービス側へ保存する方式もあります。後者のエージェントは対応するスレッドの型しか受け付けず、組み合わせを間違えるとその場で例外になります。
- ベクトル検索の部分だけ切り離して使える — データモデル——保存するレコードの型——に注釈を付けて主キー、絞り込みに使う項目、ベクトルを宣言すると、Azure AI SearchやPostgres、Qdrant、Redis、Weaviate、Pinecone、メモリ上の簡易ストアなど十数種類を同じ書き方で扱えます。公式文書はこの実装群が本体に依存しないと明記しており、.NETでは抽象部分が別のパッケージとして配られます。接続部分の保守元も一覧されていて、OracleやElastic、Couchbaseは各データベースの提供元が担当しています。
semantic-kernelを選ぶ前に
- Microsoftは後継をAgent Frameworkと位置づけており、v1.xに約束されているのは、後継が正式版となった2026年4月から最低1年間の重大な不具合とセキュリティ修正までです。
- マルチエージェントの制御機能とProcess Frameworkは実験段階の扱いで、.NET向けにはプレリリース版のパッケージしかなく、旧来のグループチャットAPIは保守終了となりましたが移行ガイドが用意されています。
スター推移
8月17日〜8月28日 · +51
よくある質問
semantic-kernelは商用利用できますか?
semantic-kernelはMITライセンスで公開されています。OSI承認のオープンソースライセンスで、商用利用が認められています。
semantic-kernelはどの形で使えますか?
semantic-kernelはセルフホスト・ローカル実行の形で利用できます。
ドキュメント
microsoft/semantic-kernel のREADMEより転載(MIT)。 原文を読む ↗
Semantic Kernel
[!IMPORTANT] Semantic Kernel is now Microsoft Agent Framework! Microsoft Agent Framework (MAF) is the enterprise‑ready successor to Semantic Kernel. Microsoft Agent Framework is now available at version 1.0 as a production-ready release: stable APIs, and a commitment to long-term support. Whether you’re building a single assistant or orchestrating a fleet of specialized agents, Microsoft Agent Framework 1.0 gives you enterprise-grade multi-agent orchestration, multi-provider model support, and cross-runtime interoperability via A2A and MCP.
Learn more about Semantic Kernel and Agent Framework here: Semantic Kernel and Microsoft Agent Framework on the Agent Framework blog, and try out the Semantic Kernel migration guide.
Build intelligent AI agents and multi-agent systems with this enterprise-ready orchestration framework
What is Semantic Kernel?
Semantic Kernel is a model-agnostic SDK that empowers developers to build, orchestrate, and deploy AI agents and multi-agent systems. Whether you’re building a simple chatbot or a complex multi-agent workflow, Semantic Kernel provides the tools you need with enterprise-grade reliability and flexibility.
System Requirements
- Python: 3.10+
- .NET: .NET 10.0+
- Java: JDK 17+
- OS Support: Windows, macOS, Linux
Key Features
- Model Flexibility: Connect to any LLM with built-in support for OpenAI, Azure OpenAI, Hugging Face, NVidia and more
- Agent Framework: Build modular AI agents with access to tools/plugins, memory, and planning capabilities
- Multi-Agent Systems: Orchestrate complex workflows with collaborating specialist agents
- Plugin Ecosystem: Extend with native code functions, prompt templates, OpenAPI specs, or Model Context Protocol (MCP)
- Vector DB Support: Seamless integration with Azure AI Search, Elasticsearch, Chroma, and more
- Multimodal Support: Process text, vision, and audio inputs
- Local Deployment: Run with Ollama, LMStudio, or ONNX
- Process Framework: Model complex business processes with a structured workflow approach
- Enterprise Ready: Built for observability, security, and stable APIs
Installation
First, set the environment variable for your AI Services:
Azure OpenAI:
export AZURE_OPENAI_API_KEY=AAA....
or OpenAI directly:
export OPENAI_API_KEY=sk-...
Python
pip install semantic-kernel
.NET
dotnet add package Microsoft.SemanticKernel
dotnet add package Microsoft.SemanticKernel.Agents.Core
Java
See semantic-kernel-java build for instructions.
Quickstart
Basic Agent - Python
Create a simple assistant that responds to user prompts:
import asyncio
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion
async def main():
# Initialize a chat agent with basic instructions
agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="SK-Assistant",
instructions="You are a helpful assistant.",
)
# Get a response to a user message
response = await agent.get_response(messages="Write a haiku about Semantic Kernel.")
print(response.content)
asyncio.run(main())
# Output:
# Language's essence,
# Semantic threads intertwine,
# Meaning's core revealed.
Basic Agent - .NET
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(
Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT"),
Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"),
Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY")
);
var kernel = builder.Build();
ChatCompletionAgent agent =
new()
{
Name = "SK-Agent",
Instructions = "You are a helpful assistant.",
Kernel = kernel,
};
await foreach (AgentResponseItem<ChatMessageContent> response
in agent.InvokeAsync("Write a haiku about Semantic Kernel."))
{
Console.WriteLine(response.Message);
}
// Output:
// Language's essence,
// Semantic threads intertwine,
// Meaning's core revealed.
Agent with Plugins - Python
Enhance your agent with custom tools (plugins) and structured output:
import asyncio
from typing import Annotated
from pydantic import BaseModel
from semantic_kernel.agents import ChatCompletionAgent
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatPromptExecutionSettings
from semantic_kernel.functions import kernel_function, KernelArguments
class MenuPlugin:
@kernel_function(description="Provides a list of specials from the menu.")
def get_specials(self) -> Annotated[str, "Returns the specials from the menu."]:
return """
Special Soup: Clam Chowder
Special Salad: Cobb Salad
Special Drink: Chai Tea
"""
@kernel_function(description="Provides the price of the requested menu item.")
def get_item_price(
self, menu_item: Annotated[str, "The name of the menu item."]
) -> Annotated[str, "Returns the price of the menu item."]:
return "$9.99"
class MenuItem(BaseModel):
price: float
name: str
async def main():
# Configure structured output format
settings = OpenAIChatPromptExecutionSettings()
settings.response_format = MenuItem
# Create agent with plugin and settings
agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="SK-Assistant",
instructions="You are a helpful assistant.",
plugins=[MenuPlugin()],
arguments=KernelArguments(settings)
)
response = await agent.get_response(messages="What is the price of the soup special?")
print(response.content)
# Output:
# The price of the Clam Chowder, which is the soup special, is $9.99.
asyncio.run(main())
Agent with Plugin - .NET
using System.ComponentModel;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(
Environment.GetEnvironmentVariable("AZURE_OPENAI_DEPLOYMENT"),
Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT"),
Environment.GetEnvironmentVariable("AZURE_OPENAI_API_KEY")
);
var kernel = builder.Build();
kernel.Plugins.Add(KernelPluginFactory.CreateFromType<MenuPlugin>());
ChatCompletionAgent agent =
new()
{
Name = "SK-Assistant",
Instructions = "You are a helpful assistant.",
Kernel = kernel,
Arguments = new KernelArguments(new PromptExecutionSettings() { FunctionChoiceBehavior = FunctionChoiceBehavior.Auto() })
};
await foreach (AgentResponseItem<ChatMessageContent> response
in agent.InvokeAsync("What is the price of the soup special?"))
{
Console.WriteLine(response.Message);
}
sealed class MenuPlugin
{
[KernelFunction, Description("Provides a list of specials from the menu.")]
public string GetSpecials() =>
"""
Special Soup: Clam Chowder
Special Salad: Cobb Salad
Special Drink: Chai Tea
""";
[KernelFunction, Description("Provides the price of the requested menu item.")]
public string GetItemPrice(
[Description("The name of the menu item.")]
string menuItem) =>
"$9.99";
}
Multi-Agent System - Python
Build a system of specialized agents that can collaborate:
import asyncio
from semantic_kernel.agents import ChatCompletionAgent, ChatHistoryAgentThread
from semantic_kernel.connectors.ai.open_ai import AzureChatCompletion, OpenAIChatCompletion
billing_agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="BillingAgent",
instructions="You handle billing issues like charges, payment methods, cycles, fees, discrepancies, and payment failures."
)
refund_agent = ChatCompletionAgent(
service=AzureChatCompletion(),
name="RefundAgent",
instructions="Assist users with refund inquiries, including eligibility, policies, processing, and status updates.",
)
triage_agent = ChatCompletionAgent(
service=OpenAIChatCompletion(),
name="TriageAgent",
instructions="Evaluate user requests and forward them to BillingAgent or RefundAgent for targeted assistance."
" Provide the full answer to the user containing any information from the agents",
plugins=[billing_agent, refund_agent],
)
thread: ChatHistoryAgentThread = None
async def main() -> None:
print("Welcome to the chat bot!\n Type 'exit' to exit.\n Try to get some billing or refund help.")
while True:
user_input = input("User:> ")
if user_input.lower().strip() == "exit":
print("\n\nExiting chat...")
return False
response = await triage_agent.get_response(
messages=user_input,
thread=thread,
)
if response:
print(f"Agent :> {response}")
# Agent :> I understand that you were charged twice for your subscription last month, and I'm here to assist you with resolving this issue. Here’s what we need to do next:
# 1. **Billing Inquiry**:
# - Please provide the email address or account number associated with your subscription, the date(s) of the charges, and the amount charged. This will allow the billing team to investigate the discrepancy in the charges.
# 2. **Refund Process**:
# - For the refund, please confirm your subscription type and the email address associated with your account.
# - Provide the dates and transaction IDs for the charges you believe were duplicated.
# Once we have these details, we will be able to:
# - Check your billing history for any discrepancies.
# - Confirm any duplicate charges.
# - Initiate a refund for the duplicate payment if it qualifies. The refund process usually takes 5-10 business days after approval.
# Please provide the necessary details so we can proceed with resolving this issue for you.
if __name__ == "__main__":
asyncio.run(main())
Where to Go Next
- 📖 Try our Getting Started Guide or learn about Building Agents
- 🔌 Explore over 100 Detailed Samples
- 💡 Learn about core Semantic Kernel Concepts
API References
Troubleshooting
Common Issues
- Authentication Errors: Check that your API key environment variables are correctly set
- Model Availability: Verify your Azure OpenAI deployment or OpenAI model access
Getting Help
- Check our GitHub issues for known problems
- Search the Discord community for solutions
- Include your SDK version and full error messages when asking for help
Join the community
We welcome your contributions and suggestions to the SK community! One of the easiest ways to participate is to engage in discussions in the GitHub repository. Bug reports and fixes are welcome!
For new features, components, or extensions, please open an issue and discuss with us before sending a PR. This is to avoid rejection as we might be taking the core in a different direction, but also to consider the impact on the larger ecosystem.
To learn more and get started:
-
Read the documentation
-
Learn how to contribute to the project
-
Ask questions in the GitHub discussions
-
Ask questions in the Discord community
-
Follow the team on our blog