Skip to content

default_handler

autogen.beta.network.client.handlers.default_handler async #

default_handler(envelope, client)

Route an inbound envelope to its handler.

Override via :meth:AgentClient.on_envelope — the default delegates to the per-event helpers above which can be composed in custom handlers.

Substantive routing is delegated to the session's adapter via adapter.extract_turn_input (returns empty for envelope types the adapter doesn't act on, ending the handler chain).

Source code in autogen/beta/network/client/handlers.py
async def default_handler(envelope: Envelope, client: "AgentClient") -> None:
    """Route an inbound envelope to its handler.

    Override via :meth:`AgentClient.on_envelope` — the default
    delegates to the per-event helpers above which can be composed in
    custom handlers.

    Substantive routing is delegated to the session's adapter via
    ``adapter.extract_turn_input`` (returns empty for envelope types
    the adapter doesn't act on, ending the handler chain).
    """
    event_type = envelope.event_type
    if event_type == EV_SESSION_INVITE:
        await _auto_ack_invite(envelope, client)
        return
    if event_type.startswith("ag2.session.") or event_type.startswith("ag2.task."):
        # Bookkeeping: state changes are visible via Session.info();
        # task events are mirrored separately by TaskMirror.
        return
    await _process_substantive(envelope, client)