Skip to content

feat: add azure-ai-agentserver-github package (Copilot SDK adapter)#45894

Open
jodeklotzms wants to merge 3 commits intomainfrom
feature/agentserver-github
Open

feat: add azure-ai-agentserver-github package (Copilot SDK adapter)#45894
jodeklotzms wants to merge 3 commits intomainfrom
feature/agentserver-github

Conversation

@jodeklotzms
Copy link

Summary

Initial scaffold of the azure-ai-agentserver-github package — a GitHub Copilot SDK adapter for Azure AI Agent Server. Bridges the Copilot SDK event model to the Foundry Responses API (RAPI) protocol.

SDK spec approved Mar 19 at coreai-microsoft/foundrysdk_specs.

Package exports

  • GitHubCopilotAdapter: convenience class with skill discovery + conversation history bootstrap
  • CopilotAdapter: core adapter (BYOK auth, n:n event mapping, Tool ACL, OTel)
  • ToolAcl: YAML-based tool permission system

Validated

  • End-to-end on ADC (deployed pkg-test-02, agent responds correctly)
  • Follows azure-ai-agentserver-langgraph package pattern
  • Imports verified against agentserver-core 1.0.0b14-b17 + github-copilot-sdk 0.2.0

Hero code sample

from azure.ai.agentserver.github import GitHubCopilotAdapter

adapter = GitHubCopilotAdapter.from_project(".")
adapter.run()

Test plan

  • Syntax + import validation (local)
  • Integration test agent deployed and invoked on ADC
  • CI pipeline (needs bootstrapping - first package in this area)

🤖 Generated with Claude Code

jodeklotzms and others added 3 commits March 23, 2026 11:38
Initial package structure for the GitHub Copilot SDK adapter for
Azure AI Agent Server. Follows the established pattern from
azure-ai-agentserver-langgraph.

Package exports:
- GitHubCopilotAdapter: convenience class with skill discovery + history bootstrap
- CopilotAdapter: core adapter (BYOK auth, n:n event mapping, Tool ACL, OTel)
- ToolAcl: YAML-based tool permission system

Validated: syntax check + import resolution against agentserver-core 1.0.0b14
and github-copilot-sdk 0.1.33rc4.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Minimal test agent that imports GitHubCopilotAdapter from the package
(not vendored code), deploys to ADC, and invokes. Proves the package
works as a pip-installable dependency.

- test_agent/main.py: 5-line entry point using from_project(".")
- deploy.py: stages package source + agent, builds via ACR Tasks
- invoke.py: REST invocation via az CLI

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Replace @self.app.on_event("startup") with direct filter registration
  (Starlette 1.0 removed on_event in favor of lifespan)
- Fix logs.py PROJECT_ROOT to find .env at package root

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jodeklotzms jodeklotzms requested a review from JC-386 as a code owner March 25, 2026 06:53
Copilot AI review requested due to automatic review settings March 25, 2026 06:53
@jodeklotzms jodeklotzms requested a review from lusu-msft as a code owner March 25, 2026 06:53
@github-actions github-actions bot added the Hosted Agents sdk/agentserver/* label Mar 25, 2026
@microsoft-github-policy-service
Copy link
Contributor

@jodeklotzms please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.

@microsoft-github-policy-service agree [company="{your company}"]

Options:

  • (default - no company specified) I have sole ownership of intellectual property rights to my Submissions and I am not making Submissions in the course of work for my employer.
@microsoft-github-policy-service agree
  • (when company given) I am making Submissions in the course of work for my employer (or my employer has intellectual property rights in my Submissions by contract or applicable law). I have permission from my employer to make Submissions and enter into this Agreement on behalf of my employer. By signing below, the defined term “You” includes me and my employer.
@microsoft-github-policy-service agree company="Microsoft"
Contributor License Agreement

Contribution License Agreement

This Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
and conveys certain license rights to Microsoft Corporation and its affiliates (“Microsoft”) for Your
contributions to Microsoft open source projects. This Agreement is effective as of the latest signature
date below.

  1. Definitions.
    “Code” means the computer software code, whether in human-readable or machine-executable form,
    that is delivered by You to Microsoft under this Agreement.
    “Project” means any of the projects owned or managed by Microsoft and offered under a license
    approved by the Open Source Initiative (www.opensource.org).
    “Submit” is the act of uploading, submitting, transmitting, or distributing code or other content to any
    Project, including but not limited to communication on electronic mailing lists, source code control
    systems, and issue tracking systems that are managed by, or on behalf of, the Project for the purpose of
    discussing and improving that Project, but excluding communication that is conspicuously marked or
    otherwise designated in writing by You as “Not a Submission.”
    “Submission” means the Code and any other copyrightable material Submitted by You, including any
    associated comments and documentation.
  2. Your Submission. You must agree to the terms of this Agreement before making a Submission to any
    Project. This Agreement covers any and all Submissions that You, now or in the future (except as
    described in Section 4 below), Submit to any Project.
  3. Originality of Work. You represent that each of Your Submissions is entirely Your original work.
    Should You wish to Submit materials that are not Your original work, You may Submit them separately
    to the Project if You (a) retain all copyright and license information that was in the materials as You
    received them, (b) in the description accompanying Your Submission, include the phrase “Submission
    containing materials of a third party:” followed by the names of the third party and any licenses or other
    restrictions of which You are aware, and (c) follow any other instructions in the Project’s written
    guidelines concerning Submissions.
  4. Your Employer. References to “employer” in this Agreement include Your employer or anyone else
    for whom You are acting in making Your Submission, e.g. as a contractor, vendor, or agent. If Your
    Submission is made in the course of Your work for an employer or Your employer has intellectual
    property rights in Your Submission by contract or applicable law, You must secure permission from Your
    employer to make the Submission before signing this Agreement. In that case, the term “You” in this
    Agreement will refer to You and the employer collectively. If You change employers in the future and
    desire to Submit additional Submissions for the new employer, then You agree to sign a new Agreement
    and secure permission from the new employer before Submitting those Submissions.
  5. Licenses.
  • Copyright License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license in the
    Submission to reproduce, prepare derivative works of, publicly display, publicly perform, and distribute
    the Submission and such derivative works, and to sublicense any or all of the foregoing rights to third
    parties.
  • Patent License. You grant Microsoft, and those who receive the Submission directly or
    indirectly from Microsoft, a perpetual, worldwide, non-exclusive, royalty-free, irrevocable license under
    Your patent claims that are necessarily infringed by the Submission or the combination of the
    Submission with the Project to which it was Submitted to make, have made, use, offer to sell, sell and
    import or otherwise dispose of the Submission alone or with the Project.
  • Other Rights Reserved. Each party reserves all rights not expressly granted in this Agreement.
    No additional licenses or rights whatsoever (including, without limitation, any implied licenses) are
    granted by implication, exhaustion, estoppel or otherwise.
  1. Representations and Warranties. You represent that You are legally entitled to grant the above
    licenses. You represent that each of Your Submissions is entirely Your original work (except as You may
    have disclosed under Section 3). You represent that You have secured permission from Your employer to
    make the Submission in cases where Your Submission is made in the course of Your work for Your
    employer or Your employer has intellectual property rights in Your Submission by contract or applicable
    law. If You are signing this Agreement on behalf of Your employer, You represent and warrant that You
    have the necessary authority to bind the listed employer to the obligations contained in this Agreement.
    You are not expected to provide support for Your Submission, unless You choose to do so. UNLESS
    REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING, AND EXCEPT FOR THE WARRANTIES
    EXPRESSLY STATED IN SECTIONS 3, 4, AND 6, THE SUBMISSION PROVIDED UNDER THIS AGREEMENT IS
    PROVIDED WITHOUT WARRANTY OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF
    NONINFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
  2. Notice to Microsoft. You agree to notify Microsoft in writing of any facts or circumstances of which
    You later become aware that would make Your representations in this Agreement inaccurate in any
    respect.
  3. Information about Submissions. You agree that contributions to Projects and information about
    contributions may be maintained indefinitely and disclosed publicly, including Your name and other
    information that You submit with Your Submission.
  4. Governing Law/Jurisdiction. This Agreement is governed by the laws of the State of Washington, and
    the parties consent to exclusive jurisdiction and venue in the federal courts sitting in King County,
    Washington, unless no federal subject matter jurisdiction exists, in which case the parties consent to
    exclusive jurisdiction and venue in the Superior Court of King County, Washington. The parties waive all
    defenses of lack of personal jurisdiction and forum non-conveniens.
  5. Entire Agreement/Assignment. This Agreement is the entire agreement between the parties, and
    supersedes any and all prior agreements, understandings or communications, written or oral, between
    the parties relating to the subject matter hereof. This Agreement may be assigned by Microsoft.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new azure-ai-agentserver-github package that adapts the GitHub Copilot SDK session/event model to Azure AI Agent Server (Foundry Responses API / RAPI), plus local integration deploy/invoke tooling and a minimal hosted-agent test project.

Changes:

  • Introduces CopilotAdapter / GitHubCopilotAdapter, request/response conversion utilities, and a YAML-based ToolAcl.
  • Adds package scaffolding (pyproject, versioning, manifest, README, samples README).
  • Adds integration test agent assets + scripts to deploy/invoke/stream logs against Foundry ADC.

Reviewed changes

Copilot reviewed 25 out of 27 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
sdk/agentserver/azure-ai-agentserver-github/tests/integration/test_agent/skills/hello/SKILL.md Minimal “hello” skill definition for end-to-end validation.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/test_agent/requirements.txt Dependencies for the containerized test agent.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/test_agent/main.py Minimal agent entrypoint using GitHubCopilotAdapter.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/test_agent/Dockerfile Container image for deploying the test agent (installs staged package).
sdk/agentserver/azure-ai-agentserver-github/tests/integration/test_agent/AGENTS.md Agent instructions used by the test agent.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/logs.py Helper script to stream hosted agent console logs.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/invoke.py Helper script to invoke the deployed agent via Foundry Responses API.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/deploy.py Helper script to stage/build/push image via ACR Tasks and create/update agent.
sdk/agentserver/azure-ai-agentserver-github/tests/integration/README.md Documentation for running integration deploy/invoke workflow.
sdk/agentserver/azure-ai-agentserver-github/tests/init.py Marks tests package.
sdk/agentserver/azure-ai-agentserver-github/samples/README.md Minimal quick-start sample snippet.
sdk/agentserver/azure-ai-agentserver-github/pyproject.toml Package metadata, dependencies, ruff config, build settings.
sdk/agentserver/azure-ai-agentserver-github/dev_requirements.txt Dev dependencies for local iteration.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/py.typed Declares typing support.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/_version.py Package version constant.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/_tool_acl.py YAML ACL parser/evaluator for Copilot permission requests.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/_copilot_response_converter.py Converts Copilot session events / text into RAPI response/event shapes.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/_copilot_request_converter.py Converts Foundry request input + attachments into Copilot prompt/attachments.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/_copilot_adapter.py Core adapter implementation (session mgmt, streaming/non-streaming, ACL).
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/github/init.py Public exports + package version.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/agentserver/init.py Namespace package setup.
sdk/agentserver/azure-ai-agentserver-github/azure/ai/init.py Namespace package setup.
sdk/agentserver/azure-ai-agentserver-github/azure/init.py Namespace package setup.
sdk/agentserver/azure-ai-agentserver-github/README.md Package README with usage + env vars.
sdk/agentserver/azure-ai-agentserver-github/MANIFEST.in sdist content rules.
sdk/agentserver/azure-ai-agentserver-github/LICENSE MIT license text.
sdk/agentserver/azure-ai-agentserver-github/CHANGELOG.md Initial changelog for 1.0.0b1.

Comment on lines +99 to +107
def convert_attachments(self) -> ConvertedAttachments:
"""Extract file and image attachments from the request's content parts.

Scans all messages in ``input`` for ``input_file`` and ``input_image``
content parts and materialises their data onto disk as temporary files,
returning :class:`ConvertedAttachments` with Copilot SDK
``FileAttachment`` dicts and a list of temp paths to clean up.

Supported cases:
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The attachment + prompt conversion logic is non-trivial (multiple input shapes, data-URI decoding, temp file lifecycle) but there are no unit tests added alongside it. Other agentserver adapters do have unit tests (e.g., azure-ai-agentserver-langgraph/tests/unit_tests/test_langgraph_request_converter.py). Adding unit tests for convert() and convert_attachments() would help prevent regressions.

Copilot uses AI. Check for mistakes.
Comment on lines +488 to +492
if not self._project_endpoint:
return None
try:
openai_client = await self._create_openai_client()
items = []
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHubCopilotAdapter._load_conversation_history references self._project_endpoint and self._create_openai_client(), but FoundryCBAgent in azure-ai-agentserver-core doesn’t define these members. As written this will raise AttributeError on first cold-start bootstrap attempt. Please either implement history loading using an explicit client available in this package (or via context/env), or remove/guard this feature until the base class provides the needed API.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +27
import dataclasses
import json
import logging as _logging
import os
import pathlib
import time
import uuid
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Several imports in this file appear unused (e.g., dataclasses, json, uuid). With ruff selecting F rules, this will fail lint (F401). Please remove unused imports or use them if they’re intended for upcoming functionality.

Suggested change
import dataclasses
import json
import logging as _logging
import os
import pathlib
import time
import uuid
import logging as _logging
import os
import pathlib
import time

Copilot uses AI. Check for mistakes.
from copilot import CopilotClient
from copilot.generated.session_events import SessionEventType
from copilot.types import PermissionRequestResult, ProviderConfig
from opentelemetry import context as otel_context, trace
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otel_context/trace are imported but not used in this module. Since ruff enables Pyflakes (F), this should be cleaned up to avoid F401 lint failures.

Suggested change
from opentelemetry import context as otel_context, trace

Copilot uses AI. Check for mistakes.
from azure.ai.agentserver.core.server.common.agent_run_context import AgentRunContext

from ._copilot_request_converter import ConvertedAttachments, CopilotRequestConverter
from ._copilot_response_converter import CopilotResponseConverter, CopilotStreamingResponseConverter
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CopilotStreamingResponseConverter is imported but never referenced in this module, which will trigger ruff/Pyflakes F401. Either remove the import or switch _run_streaming over to use this converter to avoid duplicating streaming event logic.

Suggested change
from ._copilot_response_converter import CopilotResponseConverter, CopilotStreamingResponseConverter
from ._copilot_response_converter import CopilotResponseConverter

Copilot uses AI. Check for mistakes.
ResponseContentPartAddedEvent,
ResponseContentPartDoneEvent,
ResponseCreatedEvent,
ResponseError,
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseError is imported but not used in this module. With ruff’s F rules enabled, this will raise F401 unless removed or referenced.

Suggested change
ResponseError,

Copilot uses AI. Check for mistakes.
Comment on lines +105 to +109
def main():
parser = argparse.ArgumentParser(description="Stream container console logs from a deployed agent")
parser.add_argument("--name", required=True, help="Agent name")
parser.add_argument("--session", required=True, help="Session ID (from invoke output)")
args = parser.parse_args()
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logs.py docstring claims --session is optional and shows python scripts/logs.py ..., but --session is marked required=True and the file lives at tests/integration/logs.py. Either update the docs to match the current CLI, or implement the “use last session” behavior and fix the invocation path in the usage text.

Copilot uses AI. Check for mistakes.
Comment on lines +195 to +196
token = self._credential.get_token(_COGNITIVE_SERVICES_SCOPE).token
self._session_config["provider"]["bearer_token"] = token
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In BYOK (Managed Identity) mode, _session_config['provider'] is built as a ProviderConfig instance, but _refresh_token_if_needed treats it like a dict (['bearer_token']). This will raise at runtime and prevent token refresh. Update the code to refresh the token by mutating/replacing the ProviderConfig object (or store provider as a plain dict consistently).

Suggested change
token = self._credential.get_token(_COGNITIVE_SERVICES_SCOPE).token
self._session_config["provider"]["bearer_token"] = token
token = self._credential.get_token(_COGNITIVE_SERVICES_SCOPE).token
provider = self._session_config.get("provider")
# In BYOK (Managed Identity) mode, provider may be a ProviderConfig instance.
# In other modes, it may be a plain dict. Support both representations.
if isinstance(provider, ProviderConfig):
# Replace the ProviderConfig with an updated copy carrying the new bearer_token.
try:
updated_provider = dataclasses.replace(provider, bearer_token=token)
except TypeError:
# Fallback in case ProviderConfig is not a dataclass or bearer_token is not a field.
# Mutate the attribute directly if it exists.
if hasattr(provider, "bearer_token"):
provider.bearer_token = token
updated_provider = provider
else:
updated_provider = provider
self._session_config["provider"] = updated_provider
elif isinstance(provider, dict):
provider["bearer_token"] = token

Copilot uses AI. Check for mistakes.
import os
import re
from pathlib import Path
from typing import Any, Dict, Iterable, List, Literal, Optional
Copy link

Copilot AI Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typing.Iterable is imported but unused, which should fail ruff (F401). Please remove the unused import.

Suggested change
from typing import Any, Dict, Iterable, List, Literal, Optional
from typing import Any, Dict, List, Literal, Optional

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Hosted Agents sdk/agentserver/*

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants