microsoft/autogen · error · AssertionError

message parameter not found in function signature

Error message

message parameter not found in function signature

What it means

Error "message parameter not found in function signature" thrown in microsoft/autogen.

Source

Thrown at python/packages/autogen-core/src/autogen_core/_routed_agent.py:123

        1. `self`
        2. `message`: The message to be handled, this must be type-hinted with the message type that it is intended to handle.
        3. `ctx`: A :class:`autogen_core.MessageContext` object.
    - The method must be type hinted with what message types it can return as a response, or it can return `None` if it does not return anything.

    Handlers can handle more than one message type by accepting a Union of the message types. It can also return more than one message type by returning a Union of the message types.

    Args:
        func: The function to be decorated.
        strict: If `True`, the handler will raise an exception if the message type or return type is not in the target types. If `False`, it will log a warning instead.
        match: A function that takes the message and the context as arguments and returns a boolean. This is used for secondary routing after the message type. For handlers addressing the same message type, the match function is applied in alphabetical order of the handlers and the first matching handler will be called while the rest are skipped. If `None`, the first handler in alphabetical order matching the same message type will be called.
    """

    def decorator(
        func: Callable[[AgentT, ReceivesT, MessageContext], Coroutine[Any, Any, ProducesT]],
    ) -> MessageHandler[AgentT, ReceivesT, ProducesT]:
        type_hints = get_type_hints(func)
        if "message" not in type_hints:
            raise AssertionError("message parameter not found in function signature")

        if "return" not in type_hints:
            raise AssertionError("return parameter not found in function signature")

        # Get the type of the message parameter
        target_types = get_types(type_hints["message"])
        if target_types is None:
            raise AssertionError("Message type not found")

        # print(type_hints)
        return_types = get_types(type_hints["return"])

        if return_types is None:
            raise AssertionError("Return type not found")

        # Convert target_types to list and stash

        @wraps(func)

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Include a message parameter in the handler

Example fix

async def handler(self, message: MyMsg, ctx) -> ...

When it happens

Trigger: Thrown at python/packages/autogen-core/src/autogen_core/_routed_agent.py:123 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/267c3aeaa1d3e61e. Report an issue: GitHub.