microsoft/semantic-kernel · error · TypeError

Orchestration must have concrete types for all type paramete

Error message

Orchestration must have concrete types for all type parameters.

What it means

After resolving type parameters (from either __orig_class__ or __orig_bases__), _set_types requires both t_in and t_out to be concrete. If either resolves to None — e.g. a TypeVar with no default that was never bound — the orchestration cannot (de)serialize input/output and is rejected.

Source

Thrown at python/semantic_kernel/agents/orchestration/orchestration_base.py:179

            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.

        This method is non-blocking and will return immediately.
        To wait for the result, use the `get` method of the `OrchestrationResult` object.

        Args:
            task (str, DefaultTypeAlias, TIn): The task to be executed by the agents.
            runtime (CoreRuntime): The runtime environment for the agents.
        """
        self._set_types()

        orchestration_result = OrchestrationResult[self.t_out]()  # type: ignore[name-defined]

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Bind both parameters to concrete types: subclass as `OrchestrationBase[str, str]` or instantiate `MyOrchestration[str, str](...)`.
  2. Give your TypeVars defaults (Python 3.12+): `T = TypeVar('T', default=str)`.
  3. Ensure both base-class args are real types, not unresolved TypeVars with no default.

Example fix

// before
T = TypeVar('T')  # no default
class MyOrch(OrchestrationBase[T, T]):  # T unbound at instantiate -> raises
    pass
MyOrch(members)

// after
class MyOrch(OrchestrationBase[str, str]):
    pass
MyOrch(members)
Defensive patterns

Strategy: type-guard

Validate before calling

# Bind both parameters to concrete types
class MyOrch(OrchestrationBase[str, str]):
    pass
MyOrch(members)
# Or, on Python 3.12+, give TypeVars defaults:
#   T = TypeVar('T', default=str)

Type guard

from typing import get_args

def params_are_concrete(cls) -> bool:
    bases = getattr(cls, "__orig_bases__", ())
    if not bases:
        return False
    return all(isinstance(a, type) for a in get_args(bases[0]))

Prevention

When it happens

Trigger: Subclassing with TypeVars that have no default and not binding them, so `getattr(arg, '__default__', None)` returns None for t_in or t_out. Also when a custom TypeVar's __default__ is None.

Common situations: Defining `T = TypeVar('T')` (no default) and subclassing `OrchestrationBase[T, T_out_unbound]`. Using Python <3.12 where TypeVar defaults aren't supported, leaving a param unbound. A subclass whose base args include an unresolved TypeVar.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/0bf71a46b1ad0326. Report an issue: GitHub.