microsoft/autogen · error · ValueError

Deployment name not initialized

Error message

Deployment name not initialized

What it means

AzureAIAgent.deployment_name raises ValueError when _deployment_name is falsy — the model deployment name was not provided at construction (or is empty), so there is nothing to report.

Solutions

  1. Provide the deployment name at construction (e.g. via the constructor's deployment/model parameter).
  2. Validate config before building the agent: fail fast if the deployment setting is missing.
  3. Guard the property read with try/except or check the underlying config value instead.

Example fix

# before
agent = AzureAIAgent(client, name="a")
print(agent.deployment_name)  # ValueError
# after
agent = AzureAIAgent(client, name="a", deployment_name="gpt-4o-deploy")
print(agent.deployment_name)
Defensive patterns

Strategy: validation

Validate before calling

deployment = os.getenv("AZURE_DEPLOYMENT")
if not deployment:
    raise SystemExit("AZURE_DEPLOYMENT is required")
agent = AzureAIAgent(client, name="a", deployment_name=deployment)

Try / catch

try:
    dn = agent.deployment_name
except ValueError:
    dn = os.environ["AZURE_DEPLOYMENT"]

Prevention

When it happens

Trigger: Constructing AzureAIAgent without a deployment_name / model deployment argument and then reading agent.deployment_name.

Common situations: Configuration built from env vars or config files where the deployment key is missing or misspelled; empty-string defaults from os.getenv("DEPLOYMENT", "").

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/865e86faede72280. Report an issue: GitHub.

Appendix: source

Thrown at python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py:389

            raise ValueError("Agent not initialized")
        return self._agent.id

    @property
    def description(self) -> str:
        if not self._description:
            raise ValueError("Description not initialized")
        return self._description

    @property
    def agent_id(self) -> str:
        if not self._agent_id:
            raise ValueError("Agent not initialized")
        return self._agent_id

    @property
    def deployment_name(self) -> str:
        if not self._deployment_name:
            raise ValueError("Deployment name not initialized")
        return self._deployment_name

    @property
    def instructions(self) -> str:
        if not self._instructions:
            raise ValueError("Instructions not initialized")
        return self._instructions

    @property
    def tools(self) -> List[ToolDefinition]:
        """
        Get the list of tools available to the agent.

        Returns:
            List[ToolDefinition]: The list of tool definitions.
        """
        return self._api_tools

View on GitHub (pinned to 027ecf0a37)