microsoft/semantic-kernel · error · AttributeError

module {__name__} has no attribute {name}

Error message

module {__name__} has no attribute {name}

What it means

The semantic_kernel.agents package uses lazy importing: __getattr__ resolves names listed in the _AGENTS dict on first access. Accessing any attribute not in that dict raises AttributeError with this message. It is purely an import/name-resolution error, usually a typo or an attempt to import a private/un-exported symbol.

Source

Thrown at python/semantic_kernel/agents/__init__.py:62

    "GroupChatOrchestration": ".orchestration.group_chat",
    "RoundRobinGroupChatManager": ".orchestration.group_chat",
    "BooleanResult": ".orchestration.group_chat",
    "StringResult": ".orchestration.group_chat",
    "MessageResult": ".orchestration.group_chat",
    "GroupChatManager": ".orchestration.group_chat",
    "MagenticOrchestration": ".orchestration.magentic",
    "ProgressLedger": ".orchestration.magentic",
    "MagenticManagerBase": ".orchestration.magentic",
    "StandardMagenticManager": ".orchestration.magentic",
}


def __getattr__(name: str):
    if name in _AGENTS:
        submod_name = _AGENTS[name]
        module = importlib.import_module(submod_name, package=__name__)
        return getattr(module, name)
    raise AttributeError(f"module {__name__} has no attribute {name}")


def __dir__():
    return list(_AGENTS.keys())

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Check the spelling against the _AGENTS dict in semantic_kernel/agents/__init__.py (it lists every exported name).
  2. Install the optional dependencies for the agent you want (e.g. openai/azure extras) — a missing dep can prevent the name from being registered.
  3. Confirm you are on a SDK version that exports the symbol; check the changelog/release notes.
  4. Import the concrete module path directly if the top-level alias is unavailable (e.g. from semantic_kernel.agents.open_ai import OpenAIAssistantAgent).

Example fix

# before
from semantic_kernel.agents import ChatCompletionAgnet  # typo
# after
from semantic_kernel.agents import ChatCompletionAgent
Defensive patterns

Strategy: validation

Validate before calling

import semantic_kernel.agents as a
name = 'ChatCompletionAgent'
assert name in a.__dir__(), f'{name} is not an exported agents attribute; check spelling/version'

Type guard

import semantic_kernel.agents as _a
def is_exported_agent(name: str) -> bool:
    return name in _a.__dir__()

Try / catch

try:
    from semantic_kernel.agents import ChatCompletionAgent
except AttributeError as e:
    # fall back to the concrete module path or install missing extras
    from semantic_kernel.agents.chat_completion.chat_completion_agent import ChatCompletionAgent

Prevention

When it happens

Trigger: from semantic_kernel.agents import SomeMisspelledName; accessing a submodule/symbol that exists in the package but isn't registered in _AGENTS; importing before the package is fully installed (missing optional dep hiding the real symbol).

Common situations: Typo in a class name (e.g. ChatCompletionAgent misspelled); expecting an agent class that requires an optional dependency that isn't installed; using an older/newer SDK version where the export name differs.

Related errors


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