{"id":5106,"date":"2026-01-27T13:37:26","date_gmt":"2026-01-27T21:37:26","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=5106"},"modified":"2026-01-28T13:42:32","modified_gmt":"2026-01-28T21:42:32","slug":"build-ai-agents-with-github-copilot-sdk-and-microsoft-agent-framework","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/build-ai-agents-with-github-copilot-sdk-and-microsoft-agent-framework\/","title":{"rendered":"Build AI Agents with GitHub Copilot SDK and Microsoft Agent Framework"},"content":{"rendered":"<p>Microsoft Agent Framework now integrates with the <a href=\"https:\/\/github.com\/github\/copilot-sdk\">GitHub Copilot SDK<\/a>, enabling you to build AI agents powered by GitHub Copilot. This integration brings together the Agent Framework&#8217;s consistent agent abstraction with GitHub Copilot&#8217;s capabilities, including function calling, streaming responses, multi-turn conversations, shell command execution, file operations, URL fetching, and Model Context Protocol (MCP) server integration \u2014 all available in both .NET and Python.<\/p>\n<h2><strong>Why Use Agent Framework with GitHub Copilot SDK?<\/strong><\/h2>\n<p>You can use the GitHub Copilot SDK on its own to build agents. So why use it through Agent Framework? Here are the key reasons:<\/p>\n<ul>\n<li><strong>Consistent agent abstraction<\/strong> \u2014 GitHub Copilot agents implement the same <code>AIAgent<\/code> (.NET) \/ <code>BaseAgent<\/code> (Python) interface as every other agent type in the framework. You can swap providers or combine them without restructuring your code.<\/li>\n<li><strong>Multi-agent workflows<\/strong> \u2014 Compose GitHub Copilot agents with other agents (Azure OpenAI, OpenAI, Anthropic, and more) in sequential, concurrent, handoff, and group chat workflows using built-in orchestrators.<\/li>\n<li><strong>Ecosystem integration<\/strong> \u2014 Access the full Agent Framework ecosystem: declarative agent definitions, A2A protocol support, and consistent patterns for function tools, sessions, and streaming across all providers.<\/li>\n<\/ul>\n<p>In short, Agent Framework lets you treat GitHub Copilot as one building block in a larger agentic system rather than a standalone tool.<\/p>\n<h2><strong>Install the GitHub Copilot Integration<\/strong><\/h2>\n<p><strong>.NET<\/strong><\/p>\n<pre><code>dotnet add package Microsoft.Agents.AI.GitHub.Copilot --prerelease<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre><code>pip install agent-framework-github-copilot --pre<\/code><\/pre>\n<h2><strong>Create a GitHub Copilot Agent<\/strong><\/h2>\n<p>Getting started is straightforward. Create a <code>CopilotClient<\/code> (in .NET) or a <code>GitHubCopilotAgent<\/code> (in Python) and start interacting with the agent.<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">using GitHub.Copilot.SDK;\r\nusing Microsoft.Agents.AI;\r\n\r\nawait using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nAIAgent agent = copilotClient.AsAIAgent();\r\n\r\nConsole.WriteLine(await agent.RunAsync(\"What is Microsoft Agent Framework?\"));<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">from agent_framework.github import GitHubCopilotAgent\r\n\r\nasync def main():\r\n    agent = GitHubCopilotAgent(\r\n        default_options={\"instructions\": \"You are a helpful assistant.\"},\r\n    )\r\n\r\n    async with agent:\r\n        result = await agent.run(\"What is Microsoft Agent Framework?\")\r\n        print(result)<\/code><\/pre>\n<h2><strong>Add Function Tools<\/strong><\/h2>\n<p>Extend your agent with custom function tools to give it domain-specific capabilities.<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">using GitHub.Copilot.SDK;\r\nusing Microsoft.Agents.AI;\r\nusing Microsoft.Extensions.AI;\r\n\r\nAIFunction weatherTool = AIFunctionFactory.Create((string location) =&gt;\r\n{\r\n    return $\"The weather in {location} is sunny with a high of 25C.\";\r\n}, \"GetWeather\", \"Get the weather for a given location.\");\r\n\r\nawait using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nAIAgent agent = copilotClient.AsAIAgent(\r\n    tools: [weatherTool],\r\n    instructions: \"You are a helpful weather agent.\");\r\n\r\nConsole.WriteLine(await agent.RunAsync(\"What's the weather like in Seattle?\"));<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">from typing import Annotated\r\nfrom pydantic import Field\r\nfrom agent_framework.github import GitHubCopilotAgent\r\n\r\ndef get_weather(\r\n    location: Annotated[str, Field(description=\"The location to get the weather for.\")],\r\n) -&gt; str:\r\n    \"\"\"Get the weather for a given location.\"\"\"\r\n    return f\"The weather in {location} is sunny with a high of 25C.\"\r\n\r\nasync def main():\r\n    agent = GitHubCopilotAgent(\r\n        default_options={\"instructions\": \"You are a helpful weather agent.\"},\r\n        tools=[get_weather],\r\n    )\r\n\r\n    async with agent:\r\n        result = await agent.run(\"What's the weather like in Seattle?\")\r\n        print(result)<\/code><\/pre>\n<h2><strong>Stream Responses<\/strong><\/h2>\n<p>For a better user experience, you can stream responses as they are generated instead of waiting for the complete result.<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">await using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nAIAgent agent = copilotClient.AsAIAgent();\r\n\r\nawait foreach (AgentResponseUpdate update in agent.RunStreamingAsync(\"Tell me a short story.\"))\r\n{\r\n    Console.Write(update);\r\n}\r\n\r\nConsole.WriteLine();<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">from agent_framework.github import GitHubCopilotAgent\r\n\r\nasync def main():\r\n    agent = GitHubCopilotAgent(\r\n        default_options={\"instructions\": \"You are a helpful assistant.\"},\r\n    )\r\n\r\n    async with agent:\r\n        print(\"Agent: \", end=\"\", flush=True)\r\n        async for chunk in agent.run_stream(\"Tell me a short story.\"):\r\n            if chunk.text:\r\n                print(chunk.text, end=\"\", flush=True)\r\n        print()<\/code><\/pre>\n<h2><strong>Multi-Turn Conversations<\/strong><\/h2>\n<p>Maintain conversation context across multiple interactions using sessions (.NET) or threads (Python).<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">await using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nawait using GitHubCopilotAgent agent = new(\r\n    copilotClient,\r\n    instructions: \"You are a helpful assistant. Keep your answers short.\");\r\n\r\nAgentSession session = await agent.GetNewSessionAsync();\r\n\r\n\/\/ First turn\r\nawait agent.RunAsync(\"My name is Alice.\", session);\r\n\r\n\/\/ Second turn - agent remembers the context\r\nAgentResponse response = await agent.RunAsync(\"What is my name?\", session);\r\nConsole.WriteLine(response); \/\/ Should mention \"Alice\"<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">from agent_framework.github import GitHubCopilotAgent\r\n\r\nasync def main():\r\n    agent = GitHubCopilotAgent(\r\n        default_options={\"instructions\": \"You are a helpful assistant.\"},\r\n    )\r\n\r\n    async with agent:\r\n        thread = agent.get_new_thread()\r\n\r\n        # First interaction\r\n        result1 = await agent.run(\"My name is Alice.\", thread=thread)\r\n        print(f\"Agent: {result1}\")\r\n\r\n        # Second interaction - agent remembers the context\r\n        result2 = await agent.run(\"What's my name?\", thread=thread)\r\n        print(f\"Agent: {result2}\")  # Should remember \"Alice\"<\/code><\/pre>\n<h2><strong>Enable Permissions<\/strong><\/h2>\n<p>By default, the agent cannot execute shell commands, read\/write files, or fetch URLs. To enable these capabilities, provide a permission handler that approves or denies requests.<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">static Task&lt;PermissionRequestResult&gt; PromptPermission(\r\n    PermissionRequest request, PermissionInvocation invocation)\r\n{\r\n    Console.WriteLine($\"\\n[Permission Request: {request.Kind}]\");\r\n    Console.Write(\"Approve? (y\/n): \");\r\n\r\n    string? input = Console.ReadLine()?.Trim().ToUpperInvariant();\r\n    string kind = input is \"Y\" or \"YES\" ? \"approved\" : \"denied-interactively-by-user\";\r\n\r\n    return Task.FromResult(new PermissionRequestResult { Kind = kind });\r\n}\r\n\r\nawait using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nSessionConfig sessionConfig = new()\r\n{\r\n    OnPermissionRequest = PromptPermission,\r\n};\r\n\r\nAIAgent agent = copilotClient.AsAIAgent(sessionConfig);\r\n\r\nConsole.WriteLine(await agent.RunAsync(\"List all files in the current directory\"));<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">from agent_framework.github import GitHubCopilotAgent\r\nfrom copilot.types import PermissionRequest, PermissionRequestResult\r\n\r\ndef prompt_permission(\r\n    request: PermissionRequest, context: dict[str, str]\r\n) -&gt; PermissionRequestResult:\r\n    kind = request.get(\"kind\", \"unknown\")\r\n    print(f\"\\n[Permission Request: {kind}]\")\r\n\r\n    response = input(\"Approve? (y\/n): \").strip().lower()\r\n    if response in (\"y\", \"yes\"):\r\n        return PermissionRequestResult(kind=\"approved\")\r\n    return PermissionRequestResult(kind=\"denied-interactively-by-user\")\r\n\r\nasync def main():\r\n    agent = GitHubCopilotAgent(\r\n        default_options={\r\n            \"instructions\": \"You are a helpful assistant that can execute shell commands.\",\r\n            \"on_permission_request\": prompt_permission,\r\n        },\r\n    )\r\n\r\n    async with agent:\r\n        result = await agent.run(\"List the Python files in the current directory\")\r\n        print(result)<\/code><\/pre>\n<h2><strong>Connect MCP Servers<\/strong><\/h2>\n<p>GitHub Copilot agents support connecting to local (stdio) and remote (HTTP) MCP servers, giving the agent access to external tools and data sources.<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">await using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nSessionConfig sessionConfig = new()\r\n{\r\n    OnPermissionRequest = PromptPermission,\r\n    McpServers = new Dictionary&lt;string, object&gt;\r\n    {\r\n        \/\/ Local stdio server\r\n        [\"filesystem\"] = new McpLocalServerConfig\r\n        {\r\n            Type = \"stdio\",\r\n            Command = \"npx\",\r\n            Args = [\"-y\", \"@modelcontextprotocol\/server-filesystem\", \".\"],\r\n            Tools = [\"*\"],\r\n        },\r\n        \/\/ Remote HTTP server\r\n        [\"microsoft-learn\"] = new McpRemoteServerConfig\r\n        {\r\n            Type = \"http\",\r\n            Url = \"https:\/\/learn.microsoft.com\/api\/mcp\",\r\n            Tools = [\"*\"],\r\n        },\r\n    },\r\n};\r\n\r\nAIAgent agent = copilotClient.AsAIAgent(sessionConfig);\r\n\r\nConsole.WriteLine(await agent.RunAsync(\"Search Microsoft Learn for 'Azure Functions' and summarize the top result\"));<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">from agent_framework.github import GitHubCopilotAgent\r\nfrom copilot.types import MCPServerConfig\r\n\r\nasync def main():\r\n    mcp_servers: dict[str, MCPServerConfig] = {\r\n        # Local stdio server\r\n        \"filesystem\": {\r\n            \"type\": \"stdio\",\r\n            \"command\": \"npx\",\r\n            \"args\": [\"-y\", \"@modelcontextprotocol\/server-filesystem\", \".\"],\r\n            \"tools\": [\"*\"],\r\n        },\r\n        # Remote HTTP server\r\n        \"microsoft-learn\": {\r\n            \"type\": \"http\",\r\n            \"url\": \"https:\/\/learn.microsoft.com\/api\/mcp\",\r\n            \"tools\": [\"*\"],\r\n        },\r\n    }\r\n\r\n    agent = GitHubCopilotAgent(\r\n        default_options={\r\n            \"instructions\": \"You are a helpful assistant with access to the filesystem and Microsoft Learn.\",\r\n            \"on_permission_request\": prompt_permission,\r\n            \"mcp_servers\": mcp_servers,\r\n        },\r\n    )\r\n\r\n    async with agent:\r\n        result = await agent.run(\"Search Microsoft Learn for 'Azure Functions' and summarize the top result\")\r\n        print(result)<\/code><\/pre>\n<h2><strong>Use GitHub Copilot in a Multi-Agent Workflow<\/strong><\/h2>\n<p>One of the key benefits of using Agent Framework is the ability to combine GitHub Copilot with other agents in a multi-agent workflow. In this example, an Azure OpenAI agent drafts a marketing tagline and a GitHub Copilot agent reviews it \u2014 all orchestrated as a sequential pipeline.<\/p>\n<p><strong>.NET<\/strong><\/p>\n<pre class=\"prettyprint language-cs language-csharp\"><code class=\"language-cs language-csharp\">using Azure.AI.OpenAI;\r\nusing Azure.Identity;\r\nusing GitHub.Copilot.SDK;\r\nusing Microsoft.Agents.AI;\r\nusing Microsoft.Agents.AI.GitHub.Copilot;\r\nusing Microsoft.Agents.AI.Workflows;\r\nusing Microsoft.Extensions.AI;\r\n\r\n\/\/ Create an Azure OpenAI agent as a copywriter\r\nvar endpoint = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_ENDPOINT\")!;\r\nvar deploymentName = Environment.GetEnvironmentVariable(\"AZURE_OPENAI_DEPLOYMENT_NAME\") ?? \"gpt-4o-mini\";\r\nvar chatClient = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())\r\n    .GetChatClient(deploymentName)\r\n    .AsIChatClient();\r\n\r\nChatClientAgent writer = new(chatClient,\r\n    \"You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt.\",\r\n    \"writer\");\r\n\r\n\/\/ Create a GitHub Copilot agent as a reviewer\r\nawait using CopilotClient copilotClient = new();\r\nawait copilotClient.StartAsync();\r\n\r\nGitHubCopilotAgent reviewer = new(copilotClient,\r\n    instructions: \"You are a thoughtful reviewer. Give brief feedback on the previous assistant message.\");\r\n\r\n\/\/ Build a sequential workflow: writer -&gt; reviewer\r\nWorkflow workflow = AgentWorkflowBuilder.BuildSequential([writer, reviewer]);\r\n\r\n\/\/ Run the workflow\r\nawait using StreamingRun run = await InProcessExecution.StreamAsync(workflow, input: prompt);\r\nawait run.TrySendMessageAsync(new TurnToken(emitEvents: true));\r\n\r\nawait foreach (WorkflowEvent evt in run.WatchStreamAsync())\r\n{\r\n    if (evt is AgentResponseUpdateEvent e)\r\n    {\r\n        Console.Write(e.Update.Text);\r\n    }\r\n}<\/code><\/pre>\n<p><strong>Python<\/strong><\/p>\n<pre class=\"prettyprint language-py\"><code class=\"language-py\">import asyncio\r\nfrom typing import cast\r\n\r\nfrom agent_framework import ChatMessage, Role, SequentialBuilder, WorkflowOutputEvent\r\nfrom agent_framework.azure import AzureOpenAIChatClient\r\nfrom agent_framework.github import GitHubCopilotAgent\r\nfrom azure.identity import AzureCliCredential\r\n\r\nasync def main():\r\n    # Create an Azure OpenAI agent as a copywriter\r\n    chat_client = AzureOpenAIChatClient(credential=AzureCliCredential())\r\n\r\n    writer = chat_client.as_agent(\r\n        instructions=\"You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt.\",\r\n        name=\"writer\",\r\n    )\r\n\r\n    # Create a GitHub Copilot agent as a reviewer\r\n    reviewer = GitHubCopilotAgent(\r\n        default_options={\"instructions\": \"You are a thoughtful reviewer. Give brief feedback on the previous assistant message.\"},\r\n        name=\"reviewer\",\r\n    )\r\n\r\n    # Build a sequential workflow: writer -&gt; reviewer\r\n    workflow = SequentialBuilder().participants([writer, reviewer]).build()\r\n\r\n    # Run the workflow\r\n    async for event in workflow.run_stream(\"Write a tagline for a budget-friendly electric bike.\"):\r\n        if isinstance(event, WorkflowOutputEvent):\r\n            messages = cast(list[ChatMessage], event.data)\r\n            for msg in messages:\r\n                name = msg.author_name or (\"assistant\" if msg.role == Role.ASSISTANT else \"user\")\r\n                print(f\"[{name}]: {msg.text}\\n\")\r\n\r\nasyncio.run(main())<\/code><\/pre>\n<p>This example shows how a single workflow can combine agents from different providers. You can extend this pattern to concurrent, handoff, and group chat workflows as well.<\/p>\n<h2><strong>More Information<\/strong><\/h2>\n<ul>\n<li><a href=\"https:\/\/github.com\/github\/copilot-sdk\">GitHub Copilot SDK<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/microsoft\/agent-framework\">Microsoft Agent Framework on GitHub<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/agent-framework\/tutorials\/overview\">Agent Framework Getting Started Tutorials<\/a><\/li>\n<\/ul>\n<h2><strong>Summary<\/strong><\/h2>\n<p>The GitHub Copilot SDK integration for Microsoft Agent Framework makes it easy to build AI agents that leverage GitHub Copilot&#8217;s capabilities. With support for function tools, streaming, multi-turn conversations, permissions, and MCP servers in both .NET and Python, you can build powerful agentic applications that interact with code, files, shell commands, and external services.<\/p>\n<p>We&#8217;re always interested in hearing from you. If you have feedback, questions or want to discuss further, feel free to reach out to us and the community on the <a href=\"https:\/\/github.com\/microsoft\/agent-framework\/discussions\">discussion boards<\/a> on GitHub! We would also love your support, if you&#8217;ve enjoyed using Agent Framework, give us a star on <a href=\"https:\/\/github.com\/microsoft\/agent-framework\">GitHub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft Agent Framework now integrates with the GitHub Copilot SDK, enabling you to build AI agents powered by GitHub Copilot. This integration brings together the Agent Framework&#8217;s consistent agent abstraction with GitHub Copilot&#8217;s capabilities, including function calling, streaming responses, multi-turn conversations, shell command execution, file operations, URL fetching, and Model Context Protocol (MCP) server integration [&hellip;]<\/p>\n","protected":false},"author":156732,"featured_media":5048,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[78,143,47,34],"tags":[],"class_list":["post-5106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net","category-agent-framework","category-announcement","category-python-2"],"acf":[],"blog_post_summary":"<p>Microsoft Agent Framework now integrates with the GitHub Copilot SDK, enabling you to build AI agents powered by GitHub Copilot. This integration brings together the Agent Framework&#8217;s consistent agent abstraction with GitHub Copilot&#8217;s capabilities, including function calling, streaming responses, multi-turn conversations, shell command execution, file operations, URL fetching, and Model Context Protocol (MCP) server integration [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/5106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/156732"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=5106"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/5106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/5048"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=5106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=5106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=5106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}