microsoft/semantic-kernel · error · TypeError
Orchestration must have two type parameters.
Error message
Orchestration must have two type parameters.
What it means
_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.
Source
Thrown at python/semantic_kernel/agents/orchestration/orchestration_base.py:169
my_orchestration = MyOrchestration(...)
```
The type parameters can be inferred from the `__orig_bases__` attribute.
"""
if all([self.t_in is not None, self.t_out is not None]):
return
try:
args = self.__orig_class__.__args__ # type: ignore[attr-defined]
if len(args) == 1:
self.t_in = args[0]
self.t_out = DefaultTypeAlias # type: ignore[assignment]
elif len(args) == 2:
self.t_in = args[0]
self.t_out = args[1]
else:
raise TypeError("Orchestration must have two type parameters.")
except AttributeError:
args = get_args(self.__orig_bases__[0]) # type: ignore[attr-defined]
if len(args) != 2:
raise TypeError("Orchestration must be subclassed with two type parameters.")
self.t_in = args[0] if isinstance(args[0], type) else getattr(args[0], "__default__", None) # type: ignore[assignment]
self.t_out = args[1] if isinstance(args[1], type) else getattr(args[1], "__default__", None) # type: ignore[assignment]
if any([self.t_in is None, self.t_out is None]):
raise TypeError("Orchestration must have concrete types for all type parameters.")
async def invoke(
self,
task: str | DefaultTypeAlias | TIn,
runtime: CoreRuntime,
) -> OrchestrationResult[TOut]:
"""Invoke the multi-agent orchestration.
View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before orch = MyOrchestration[str, int, float](members) # 3 args -> raises // after orch = MyOrchestration[str, str](members)
Defensive patterns
Strategy: validation
Validate before calling
# Parameterize with one or two concrete types orch = MyOrchestration[str, str](members) # or MyOrchestration[str](members)
Type guard
from typing import get_args
def has_valid_arity(cls) -> bool:
args = getattr(getattr(cls, "__orig_class__", None), "__args__", ())
return len(args) in (1, 2) Prevention
- 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.
When it happens
Trigger: 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__.
Common situations: Typo in generic parameterization, an empty subscript, or a custom subclass that accidentally parameterizes with three TypeVars. Misconfigured metaclass/generic machinery producing unexpected __args__.
Related errors
- Orchestration must have concrete types for all type paramete
- Orchestration must be subclassed with two type parameters.
- The members list cannot be empty.
- Configuration not found, please setup the notebooks first us
- AZURE_OPENAI_ENDPOINT is not set.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/f695dc34c91f1ee3.
Report an issue: GitHub.