microsoft/semantic-kernel · error · AgentInitializationException

Missing required configuration field(s)

Error message

Missing required configuration field(s): {', '.join(missing_params)}

What it means

Raised by CopilotStudioAgent.create_client() after settings are successfully constructed but app_client_id or tenant_id (or both) are empty/falsy. The code explicitly checks these two fields because they are mandatory for MSAL authentication and CopilotClient construction, yet the settings model itself may allow them as optional (loaded from env). It is an AgentInitializationException naming the missing field(s).

Solutions

  1. Set APP_CLIENT_ID and TENANT_ID in the environment or .env file before calling create_client().
  2. Pass them explicitly: create_client(app_client_id=..., tenant_id=...).
  3. Verify env_file_path points to the correct .env file and that values are uncommented.
  4. Use a settings preload step to check values before creating the client.

Example fix

# before
client = CopilotStudioAgent.create_client()  # no env vars set

# after
client = CopilotStudioAgent.create_client(
    app_client_id=os.environ["APP_CLIENT_ID"],
    tenant_id=os.environ["TENANT_ID"],
)
Defensive patterns

Strategy: validation

Validate before calling

missing = [f for f in ("app_client_id", "tenant_id") if not locals().get(f)]
if missing:
    raise ValueError(f"Missing required config: {missing}")
client = CopilotStudioAgent.create_client(app_client_id=app_client_id, tenant_id=tenant_id)

Try / catch

from semantic_kernel.exceptions.agent_exceptions import AgentInitializationException

try:
    client = CopilotStudioAgent.create_client()
except AgentInitializationException as exc:
    if "Missing required configuration" in str(exc):
        # load from alternative source or prompt user
        ...
    raise

Prevention

When it happens

Trigger: Calling create_client() without app_client_id/tenant_id arguments and without corresponding values in the .env file or environment variables. The settings object is built (no ValidationError) but the fields resolve to None or empty string.

Common situations: Missing APP_CLIENT_ID / TENANT_ID environment variables; .env file not found or misnamed (wrong env_file_path); values present but commented out; running in a fresh environment without copying the .env template.

Related errors


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

Appendix: source

Thrown at python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py:319

            connection_settings = CopilotStudioAgentSettings(
                app_client_id=app_client_id,
                tenant_id=tenant_id,
                environment_id=environment_id,
                agent_identifier=agent_identifier,
                cloud=cloud,
                type=copilot_agent_type,
                custom_power_platform_cloud=custom_power_platform_cloud,
                env_file_path=env_file_path,
                env_file_encoding=env_file_encoding,
                user_assertion=user_assertion,
                auth_mode=auth_mode,
            )
        except ValidationError as exc:
            raise AgentInitializationException(f"Failed to create Copilot Studio Agent settings: {exc}") from exc

        missing_params = [name for name in ("app_client_id", "tenant_id") if not getattr(connection_settings, name)]
        if missing_params:
            raise AgentInitializationException(f"Missing required configuration field(s): {', '.join(missing_params)}")

        cache_file = environ.get("TOKEN_CACHE_PATH_INTERACTIVE") or path.join(
            path.dirname(__file__), "bin", "token_cache_interactive.bin"
        )

        token = _CopilotStudioAgentTokenFactory(
            settings=connection_settings,
            cache_path=cache_file,
        ).acquire()

        return CopilotClient(connection_settings, token)

    # region Invocation Methods

    @trace_agent_get_response
    @override
    async def get_response(
        self,

View on GitHub (pinned to 6eab62d273)