Skip to content

AgentApplication.AdaptiveCard support - #518

Draft
rodrigobr-msft wants to merge 1 commit into
mainfrom
users/robrandao/adaptive-cards
Draft

AgentApplication.AdaptiveCard support#518
rodrigobr-msft wants to merge 1 commit into
mainfrom
users/robrandao/adaptive-cards

Conversation

@rodrigobr-msft

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings August 3, 2026 22:18
@rodrigobr-msft rodrigobr-msft changed the title First commit for AdaptiveCard support in AgentApplication AgentApplication.AdaptiveCard support Aug 3, 2026
@rodrigobr-msft rodrigobr-msft linked an issue Aug 3, 2026 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 AdaptiveCard route 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.value to accept non-dict payloads and adds additional ContentTypes constants 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 flips code/message in 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 flips code/message in 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dynamic adaptive card

2 participants