{"record":{"id":"f695dc34c91f1ee3","repo":"microsoft/semantic-kernel","slug":"orchestration-must-have-two-type-parameters","errorCode":null,"errorMessage":"Orchestration must have two type parameters.","messagePattern":"Orchestration must have two type parameters\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/agents/orchestration/orchestration_base.py","lineNumber":169,"sourceCode":"\n\n        my_orchestration = MyOrchestration(...)\n        ```\n        The type parameters can be inferred from the `__orig_bases__` attribute.\n        \"\"\"\n        if all([self.t_in is not None, self.t_out is not None]):\n            return\n\n        try:\n            args = self.__orig_class__.__args__  # type: ignore[attr-defined]\n            if len(args) == 1:\n                self.t_in = args[0]\n                self.t_out = DefaultTypeAlias  # type: ignore[assignment]\n            elif len(args) == 2:\n                self.t_in = args[0]\n                self.t_out = args[1]\n            else:\n                raise TypeError(\"Orchestration must have two type parameters.\")\n        except AttributeError:\n            args = get_args(self.__orig_bases__[0])  # type: ignore[attr-defined]\n\n            if len(args) != 2:\n                raise TypeError(\"Orchestration must be subclassed with two type parameters.\")\n            self.t_in = args[0] if isinstance(args[0], type) else getattr(args[0], \"__default__\", None)  # type: ignore[assignment]\n            self.t_out = args[1] if isinstance(args[1], type) else getattr(args[1], \"__default__\", None)  # type: ignore[assignment]\n\n        if any([self.t_in is None, self.t_out is None]):\n            raise TypeError(\"Orchestration must have concrete types for all type parameters.\")\n\n    async def invoke(\n        self,\n        task: str | DefaultTypeAlias | TIn,\n        runtime: CoreRuntime,\n    ) -> OrchestrationResult[TOut]:\n        \"\"\"Invoke the multi-agent orchestration.\n","sourceCodeStart":151,"sourceCodeEnd":187,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/agents/orchestration/orchestration_base.py#L151-L187","documentation":"_set_types reads the explicit generic arguments from __orig_class__ (set when you instantiate like MyOrchestration[str, str](...)). It accepts exactly one or two args (one defaults the output type); any other count is invalid. This branch fires when __orig_class__ is present but its __args__ length is not 1 or 2.","triggerScenarios":"Instantiating an orchestration subclass with the wrong number of explicit type parameters, e.g. `MyOrchestration[]` or a subclass declaration that yields zero/three-or-more args on __orig_class__.__args__.","commonSituations":"Typo in generic parameterization, an empty subscript, or a custom subclass that accidentally parameterizes with three TypeVars. Misconfigured metaclass/generic machinery producing unexpected __args__.","solutions":["Parameterize with one or two concrete types: `MyOrchestration[str]` or `MyOrchestration[str, str]`.","If your subclass declares its own TypeVars, ensure exactly one or two are exposed.","Avoid empty subscripts; rely on defaults by omitting the subscript entirely when appropriate."],"exampleFix":"// before\norch = MyOrchestration[str, int, float](members)  # 3 args -> raises\n\n// after\norch = MyOrchestration[str, str](members)","handlingStrategy":"validation","validationCode":"# Parameterize with one or two concrete types\norch = MyOrchestration[str, str](members)  # or MyOrchestration[str](members)","typeGuard":"from typing import get_args\n\ndef has_valid_arity(cls) -> bool:\n    args = getattr(getattr(cls, \"__orig_class__\", None), \"__args__\", ())\n    return len(args) in (1, 2)","tryCatchPattern":null,"preventionTips":["Subscript the orchestration with exactly one or two types at instantiation.","Avoid empty or 3+ type subscripts.","If unsure, omit the subscript and rely on defaults, or specify both types."],"tags":["semantic-kernel","orchestration","generics","type-parameters","configuration"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}