feat: add azure-ai-agentserver-activity package (Activity Protocol)#47489
Open
Hameedkunkanoor wants to merge 1 commit into
Open
feat: add azure-ai-agentserver-activity package (Activity Protocol)#47489Hameedkunkanoor wants to merge 1 commit into
Hameedkunkanoor wants to merge 1 commit into
Conversation
Initial release of the Activity Protocol host package for Azure AI Foundry hosted agents. Provides Starlette-based HTTP endpoints for Activity Protocol traffic with M365 Agents SDK integration. Package (azure-ai-agentserver-activity 1.0.0b1): - ActivityAgentServerHost with POST /activity/messages and /api/messages - Decorator API: @app.activity(type), @app.error for zero-config usage - Custom handler support for full M365 SDK control - Auto-initialization of M365 SDK from environment variables - MSAL auth patches for Foundry container MAIB auth (apply_msal_patches) - Session ID resolution (query param, header, config, UUID fallback) - Activity/session ID sanitization for header injection defense - OpenTelemetry distributed tracing and W3C Baggage propagation - Error-source classification (x-platform-error-source) Samples: - simple_activity_agent (echo bot) - streaming_activity_agent (Azure OpenAI streaming) - cards_activity_agent (Adaptive/Hero/Thumbnail/Receipt cards) - auto_signin_activity_agent (OAuth with Graph/GitHub) - semantic_kernel_activity_agent (SK agent with tools, multi-turn) - suggested_actions_activity_agent (quick-reply buttons) Tests: 26 tests covering routes, session resolution, error classification, tracing, decorator pattern, and ID sanitization edge cases.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new preview package, azure-ai-agentserver-activity (Activity Protocol host), adding Starlette endpoints intended for Azure AI Foundry hosted agents and integrating with the Microsoft 365 Agents SDK (decorator mode + custom-handler mode). It also wires the new package into the agentserver CI/test targeting so it is built and validated with the rest of the service directory.
Changes:
- Added
azure-ai-agentserver-activitypackage withActivityAgentServerHost, M365 bridge + MSAL patches, ID sanitization, tracing/baggage, and error-source classification. - Added unit tests and multiple runnable samples (simple, streaming, cards, suggested actions, semantic-kernel, auto sign-in).
- Updated
sdk/agentserver/ci.ymlandsdk/agentserver/tests.ymlto include the new package in artifact/test targeting.
Reviewed changes
Copilot reviewed 39 out of 40 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/agentserver/tests.yml | Adds activity package to test targeting string. |
| sdk/agentserver/ci.yml | Adds activity package to pipeline artifacts. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_tracing.py | Adds tracing + baggage propagation tests. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_session_headers.py | Adds session resolution/response header tests. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_server_routes.py | Adds route/endpoint behavior tests. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_sanitize_id.py | Adds _sanitize_id edge-case tests. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_id_sanitization.py | Adds end-to-end activity-id sanitization tests. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_error_source_classification.py | Adds tests for x-platform-error-source classification. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/test_decorator_pattern.py | Adds decorator wiring tests for bridge handler. |
| sdk/agentserver/azure-ai-agentserver-activity/tests/conftest.py | Adds shared fixtures + marker declaration. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/README.md | Documents available samples and usage patterns. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/simple_activity_agent/simple_activity_agent.py | Simple decorator-based echo agent sample. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/simple_activity_agent/requirements.txt | Sample dependencies. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/streaming_activity_agent/streaming_activity_agent.py | Streaming Azure OpenAI sample using streaming_response. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/streaming_activity_agent/requirements.txt | Sample dependencies. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/cards_activity_agent/cards_activity_agent.py | Rich cards sample (adaptive/hero/thumbnail/receipt). |
| sdk/agentserver/azure-ai-agentserver-activity/samples/cards_activity_agent/requirements.txt | Sample dependencies. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/suggested_actions_activity_agent/suggested_actions_activity_agent.py | Suggested actions / quick-reply buttons sample. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/suggested_actions_activity_agent/requirements.txt | Sample dependencies. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/semantic_kernel_activity_agent/semantic_kernel_activity_agent.py | Semantic Kernel multi-turn + streaming sample. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/semantic_kernel_activity_agent/requirements.txt | Sample dependencies. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/auto_signin_activity_agent/auto_signin_activity_agent.py | OAuth auto sign-in sample using handler pattern + MSAL patches. |
| sdk/agentserver/azure-ai-agentserver-activity/samples/auto_signin_activity_agent/requirements.txt | Sample dependencies. |
| sdk/agentserver/azure-ai-agentserver-activity/README.md | Package README describing host usage and API surface. |
| sdk/agentserver/azure-ai-agentserver-activity/pyrightconfig.json | Pyright config excluding samples. |
| sdk/agentserver/azure-ai-agentserver-activity/pyproject.toml | Package metadata, deps, and Azure SDK build config. |
| sdk/agentserver/azure-ai-agentserver-activity/MANIFEST.in | sdist packaging manifest. |
| sdk/agentserver/azure-ai-agentserver-activity/LICENSE | MIT license file. |
| sdk/agentserver/azure-ai-agentserver-activity/dev_requirements.txt | Dev/test requirements. |
| sdk/agentserver/azure-ai-agentserver-activity/cspell.json | Spellchecker configuration. |
| sdk/agentserver/azure-ai-agentserver-activity/CHANGELOG.md | Initial preview release changelog. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/activity/py.typed | Marks package as typed. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/activity/_version.py | Defines package version. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/activity/_m365_bridge.py | Implements M365 SDK lazy-init + bridge handler + MSAL patching. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/activity/_constants.py | Defines Activity protocol constants and header names. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/activity/_activity.py | Implements ActivityAgentServerHost endpoint, sanitization, tracing, and error handling. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/activity/init.py | Exposes public API (ActivityAgentServerHost, apply_msal_patches). |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/agentserver/init.py | Namespace package init. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/ai/init.py | Namespace package init. |
| sdk/agentserver/azure-ai-agentserver-activity/azure/init.py | Namespace package init. |
| request.method, request.url.path, str(request.query_params), | ||
| request.headers.get("content-type", ""), | ||
| ) | ||
| logger.debug("Activity endpoint headers: %s", dict(request.headers)) |
| ) | ||
| logger.debug("Activity endpoint headers: %s", dict(request.headers)) | ||
|
|
||
| inbound_conversation_id = request.headers.get(ActivityConstants.CONVERSATION_ID_HEADER, "") |
Comment on lines
+156
to
+160
| agent_app, adapter = _ensure_m365_initialized() | ||
|
|
||
| # Replay pending decorator registrations onto the real AgentApplication | ||
| if _lazy_agent_app is not None and not _lazy_agent_app._replayed: | ||
| _lazy_agent_app._replay_on(agent_app) |
Comment on lines
+6
to
+10
| import pytest | ||
| from httpx import ASGITransport, AsyncClient | ||
| from starlette.responses import JSONResponse | ||
|
|
||
| from azure.ai.agentserver.activity import ActivityAgentServerHost |
| @@ -0,0 +1,82 @@ | |||
| # Azure AI Agent Server Activity client library for Python | |||
Comment on lines
+21
to
+24
| `ActivityAgentServerHost` is an `AgentServerHost` subclass for Activity Protocol traffic. It provides: | ||
|
|
||
| - `POST /activity/messages` for inbound activities. | ||
|
|
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.
Initial release of the Activity Protocol host package for Azure AI Foundry hosted agents. Provides Starlette-based HTTP endpoints for Activity Protocol traffic with M365 Agents SDK integration.
Package (azure-ai-agentserver-activity 1.0.0b1):
Samples:
Tests: 26 tests covering routes, session resolution, error classification, tracing, decorator pattern, and ID sanitization edge cases.