Skip to content

try_activate_a2ui_extension

autogen.agents.experimental.a2ui.a2a_helpers.try_activate_a2ui_extension #

try_activate_a2ui_extension(context)

Activate the A2UI extension if the client requested it.

Call this in your AgentExecutor to negotiate A2UI support. If the client's request includes the A2UI extension URI, it is activated and the function returns True.

PARAMETER DESCRIPTION
context

The A2A request context.

TYPE: RequestContext

RETURNS DESCRIPTION
bool

True if the A2UI extension was activated, False otherwise.

Source code in autogen/agents/experimental/a2ui/a2a_helpers.py
@require_optional_import(["a2a"], "a2a")
def try_activate_a2ui_extension(context: RequestContext) -> bool:
    """Activate the A2UI extension if the client requested it.

    Call this in your ``AgentExecutor`` to negotiate A2UI support.
    If the client's request includes the A2UI extension URI, it is
    activated and the function returns True.

    Args:
        context: The A2A request context.

    Returns:
        True if the A2UI extension was activated, False otherwise.
    """
    if A2UI_EXTENSION_URI in context.requested_extensions:
        context.add_activated_extension(A2UI_EXTENSION_URI)
        return True
    return False