feat: Add Python Semantic Kernel sample agent#280
Open
Yogeshp-MSFT wants to merge 1 commit intomicrosoft:mainfrom
Open
feat: Add Python Semantic Kernel sample agent#280Yogeshp-MSFT wants to merge 1 commit intomicrosoft:mainfrom
Yogeshp-MSFT wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Python Semantic Kernel sample agent under python/semantic-kernel/sample-agent/, intended to mirror the existing .NET SK sample and follow the shared Agent 365 “generic host” pattern (MCP tooling, notifications, and observability).
Changes:
- Introduces a Semantic Kernel-based agent (
ChatCompletionAgent) with MCP tool discovery/registration and notification handling. - Adds a reusable aiohttp generic host server with optional JWT auth and notification wiring.
- Provides sample packaging/config/docs (
pyproject.toml,.env.template,ToolingManifest.json,README.md) for running in Playground and production modes.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| python/semantic-kernel/sample-agent/agent.py | Implements the Semantic Kernel agent (LLM config, MCP tools, observability scopes, notifications, cleanup). |
| python/semantic-kernel/sample-agent/agent_interface.py | Defines the async interface required by the generic host. |
| python/semantic-kernel/sample-agent/host_agent_server.py | Generic aiohttp host wiring: auth, message handling, typing indicators, notifications, shutdown cleanup. |
| python/semantic-kernel/sample-agent/mcp_tool_registration_service.py | MCP server discovery via SDK and SK plugin registration, with a manual MCP JSON-RPC fallback. |
| python/semantic-kernel/sample-agent/observability_config.py | Module-level one-time initialization of the A365 observability SDK. |
| python/semantic-kernel/sample-agent/turn_context_utils.py | Helpers to extract TurnContext details and build baggage for observability. |
| python/semantic-kernel/sample-agent/token_cache.py | In-memory cache for agentic tokens used by the observability exporter. |
| python/semantic-kernel/sample-agent/local_authentication_options.py | Loads local auth-related settings from environment variables. |
| python/semantic-kernel/sample-agent/start_with_generic_host.py | CLI entrypoint to run the agent with the generic host. |
| python/semantic-kernel/sample-agent/pyproject.toml | Declares dependencies and build config for the sample. |
| python/semantic-kernel/sample-agent/ToolingManifest.json | MCP server fallback manifest for tool discovery. |
| python/semantic-kernel/sample-agent/.env.template | Environment variable template for LLM/auth/tooling/observability configuration. |
| python/semantic-kernel/sample-agent/README.md | End-to-end sample documentation (setup, architecture, troubleshooting). |
Author
|
Hi @biswapm can you review this pr? |
56f69ec to
8ce3c8e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a new Python sample demonstrating how to build a production-ready Microsoft 365 agent using Semantic Kernel with the Microsoft Agent 365 SDK. This is the Python counterpart to the existing .NET Semantic Kernel sample (
dotnet/semantic-kernel/).What's included
New directory:
python/semantic-kernel/sample-agent/ChatCompletionAgentwithFunctionChoiceBehavior.Auto()start_with_generic_host.pyobservability_config.pyturn_context_utils.pylocal_authentication_options.pyToolingManifest.jsonFeatures
USE_AZURE_OPENAIenv varToolingManifest.jsonfallback; connection caching across turnsAUTH_HANDLER_NAME=(empty)InvokeAgentScope→InferenceScope→ExecuteToolScopewith BaggageBuilder context propagationChatHistorymaintained across turnsGenericAgentHostcompatible with Agents Playground, matching the pattern used by other Python samplesapp.on_shutdown, MCP plugin close, AI service client close, token cache clearDependencies
semantic-kernel>=1.15.0microsoft-agents-hosting-aiohttp>=0.7.0microsoft-agents-a365-tooling>=0.1.0microsoft-agents-a365-observability-core>=0.1.0microsoft-agents-a365-notifications>=0.1.0microsoft-agents-a365-runtime>=0.1.0Full list in pyproject.toml.
Testing
AUTH_HANDLER_NAME=empty)mcp_MailTools)Related samples
This follows the same architecture and conventions as:
python/claude/sample-agent/python/openai/sample-agent/dotnet/semantic-kernel/sample-agent/(the .NET equivalent)