AgentApplication.AdaptiveCard support - #518
Draft
rodrigobr-msft wants to merge 1 commit into
Draft
Conversation
AgentApplication.AdaptiveCard support
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Adaptive Card routing/response surface under microsoft_agents.hosting.core.app intended to support Action.Execute, Action.Submit, and Adaptive Card dynamic search invoke flows, plus supporting response/content-type updates in the activity models.
Changes:
- Introduces an
AdaptiveCardroute registrar (execute/submit/search) and related handler type defs/models. - Adds an Adaptive Card invoke-response factory module for common response shapes and error handling.
- Expands
AdaptiveCardInvokeResponse.valueto accept non-dict payloads and adds additionalContentTypesconstants for invoke responses/errors.
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/utils.py | Adds (currently commented-out) utility placeholder code related to search invoke validation. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/models.py | Adds dataclass models for search query params/results. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/factory.py | Adds helpers to construct AdaptiveCardInvokeResponse objects (adaptive card, search, errors, auth). |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/adaptive_card.py | Adds the Adaptive Card routing registrar (Action.Execute/Submit/Search) and invoke-response sending logic. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/adaptive_card_options.py | Adds options type intended to configure Adaptive Card behaviors (e.g., submit filter). |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/_type_defs.py | Adds protocol handler signatures for adaptive card routes. |
| libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/init.py | Package initializer (currently empty). |
| libraries/microsoft-agents-activity/microsoft_agents/activity/content_types.py | Adds content-type constants for invoke error/message/login/search responses. |
| libraries/microsoft-agents-activity/microsoft_agents/activity/adaptive_card_invoke_response.py | Broadens value to object to support more response payload shapes. |
Suppressed comments (2)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/factory.py:91
not_supported()currently passes the detailed message as the error "code" and the literal "NotSupported" as the human message, which flipscode/messagein the payload.
def not_supported(message: str) -> AdaptiveCardInvokeResponse:
return error(
HTTPStatus.NOT_IMPLEMENTED,
"NotSupported",
message,
)
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/app/adaptive_card/factory.py:99
internal_error()currently passes the detailed message as the error "code" and the literal "InternalError" as the human message, which flipscode/messagein the payload.
def internal_error(message: str) -> AdaptiveCardInvokeResponse:
return error(
HTTPStatus.INTERNAL_SERVER_ERROR,
"InternalError",
message,
)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+21
to
+26
| def search_response(result: dict | str) -> AdaptiveCardInvokeResponse: | ||
| return AdaptiveCardInvokeResponse( | ||
| status_code=HTTPStatus.OK, | ||
| type="application/vnd.microsoft.search.searchResponse", | ||
| value=result, | ||
| ) |
Comment on lines
+78
to
+83
| def bad_request(message: str) -> AdaptiveCardInvokeResponse: | ||
| return error( | ||
| HTTPStatus.BAD_REQUEST, | ||
| "BadRequest", | ||
| message, | ||
| ) |
| if invoke_value is not None: | ||
| response = await func(context, state, invoke_value.action.data) | ||
|
|
||
| await self._send_invoke_response(context, response, HTTPStatus.OK) |
Comment on lines
+1
to
+5
| # # Copyright (c) Microsoft Corporation. All rights reserved. | ||
| # # Licensed under the MIT License. | ||
|
|
||
| # import pydantic | ||
|
|
Comment on lines
21
to
+23
| status_code: int = None | ||
| type: NonEmptyString = None | ||
| value: dict[NonEmptyString, object] = None | ||
| value: object = None |
Comment on lines
+48
to
+55
| def action_execute( | ||
| self, | ||
| verb_or_selector: Selector, | ||
| *, | ||
| auth_handlers: list[str] | None = None, | ||
| **kwargs, | ||
| ) -> Callable[[ActionExecuteHandler], ActionExecuteHandler]: | ||
| """Register an ``Action.Execute`` handler that receives the action data.""" |
Comment on lines
+7
to
+10
| @dataclass | ||
| class AdaptiveCardOptions: | ||
|
|
||
| action_submit_filter: str | None = None |
Comment on lines
+41
to
+47
| class AdaptiveCard: | ||
| """Register handlers for Adaptive Card activities.""" | ||
|
|
||
| def __init__(self, app: "AgentApplication"): | ||
| """Initialize an Adaptive Card route registrar for an application.""" | ||
| self._app = app | ||
|
|
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.
No description provided.