{"record":{"id":"0c1bd57217e1eaa2","repo":"microsoft/semantic-kernel","slug":"invalid-input-message-type-type-input-message","errorCode":null,"errorMessage":"Invalid input message type: {type(input_message)}. Expected {self.t_in}.","messagePattern":"Invalid input message type: (.+?)\\. Expected (.+?)\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/orchestration/orchestration_base.py","lineNumber":319,"sourceCode":"        Args:\n            input_message (TIn): The input message to be transformed.\n\n        Returns:\n            DefaultTypeAlias: The transformed input message.\n        \"\"\"\n        if isinstance(input_message, ChatMessageContent):\n            return input_message\n\n        if isinstance(input_message, list) and all(isinstance(item, ChatMessageContent) for item in input_message):\n            return input_message\n\n        if isinstance(input_message, self.t_in):  # type: ignore[arg-type]\n            return ChatMessageContent(\n                role=AuthorRole.USER,\n                content=json.dumps(input_message.__dict__),\n            )\n\n        raise TypeError(f\"Invalid input message type: {type(input_message)}. Expected {self.t_in}.\")\n\n    def _default_output_transform(self, output_message: DefaultTypeAlias) -> TOut:\n        \"\"\"Default output transform function.\n\n        This function transforms the internal output message to the external output message.\n        If the output message is already in the correct format, it is returned as is.\n\n        Args:\n            output_message (DefaultTypeAlias): The output message to be transformed.\n\n        Returns:\n            TOut: The transformed output message.\n        \"\"\"\n        if self.t_out == DefaultTypeAlias or self.t_out in get_args(DefaultTypeAlias):\n            if isinstance(output_message, ChatMessageContent) or (\n                isinstance(output_message, list)\n                and all(isinstance(item, ChatMessageContent) for item in output_message)\n            ):","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/orchestration/orchestration_base.py#L301-L337","documentation":"Raised by the orchestration base's default input transform when the value passed into the orchestration is not ChatMessageContent, a list of ChatMessageContent, or an instance of the orchestration's configured input type (self.t_in). The default transform only knows how to convert these three shapes into chat content, so anything else is rejected. This fires when you invoke the orchestration with a message whose type does not match the generic TIn you declared.","triggerScenarios":"Calling an orchestration's invoke/invoke_stream with a payload (e.g. a raw str, dict, int, or a custom dataclass) that is not an instance of the orchestration's t_in generic parameter, and not already ChatMessageContent or a list of them. Occurs when t_in is left as a non-matching default or when the caller forgets to set an input_transform.","commonSituations":"Misconfiguring an orchestration's generic types (e.g. GroupChat[TIn=str] but passing an int), upgrading to a version where TIn defaults changed, passing a pydantic model instance whose class is not the declared t_in, or reusing an orchestration across pipelines that emit different message types.","solutions":["Pass a value whose type matches the orchestration's declared TIn (self.t_in), or pass a ChatMessageContent / list[ChatMessageContent] directly.","If you need a custom external input type, register an input_transform callable so the default transform is bypassed: orchestration = MyOrchestration(input_transform=my_transform).","Verify the generic parameter at construction, e.g. GroupChat[input_type, output_type](...), and ensure the value you pass is an instance of input_type.","If you intended to send plain text, wrap it first: ChatMessageContent(role=AuthorRole.USER, content=text)."],"exampleFix":"// before\nawait my_orchestration.invoke(\"hello world\", threads=...)\n// after\nfrom semantic_kernel.contents import ChatMessageContent, AuthorRole\nawait my_orchestration.invoke(\n    ChatMessageContent(role=AuthorRole.USER, content=\"hello world\"),\n    threads=...,\n)","handlingStrategy":"type-guard","validationCode":"from semantic_kernel.contents import ChatMessageContent\n\ndef is_valid_orchestration_input(msg, t_in) -> bool:\n    if isinstance(msg, (ChatMessageContent,)):\n        return True\n    if isinstance(msg, list) and all(isinstance(i, ChatMessageContent) for i in msg):\n        return True\n    return isinstance(msg, t_in)","typeGuard":"from typing import Any\nfrom semantic_kernel.contents import ChatMessageContent\n\ndef is_orchestration_input(value: Any) -> bool:\n    if isinstance(value, ChatMessageContent):\n        return True\n    return isinstance(value, list) and all(isinstance(i, ChatMessageContent) for i in value)","tryCatchPattern":"try:\n    result = await orchestration.invoke(message, threads=threads)\nexcept TypeError as e:\n    if \"Invalid input message type\" in str(e):\n        message = ChatMessageContent(role=AuthorRole.USER, content=str(message))\n        result = await orchestration.invoke(message, threads=threads)\n    else:\n        raise","preventionTips":["Always declare explicit TIn/TOut generics on orchestration construction.","Pass ChatMessageContent or list[ChatMessageContent] when unsure of the configured t_in.","Provide a custom input_transform for non-chat external types instead of relying on the default.","Unit-test the input boundary with each message shape your pipeline emits."],"tags":["orchestration","type-mismatch","message-transform","semantic-kernel"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}