microsoft/semantic-kernel · error · AgentInitializationException
Missing required configuration field(s): {', '.join(missing_
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).
Source
Thrown at python/semantic_kernel/agents/copilot_studio/copilot_studio_agent.py:391
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,
client_secret=client_secret,
client_certificate=client_certificate,
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,
mode=connection_settings.auth_mode,
client_secret=connection_settings.client_secret.get_secret_value()
if connection_settings.client_secret
else None,
client_certificate=Path(client_certificate) if client_certificate else None,
user_assertion=user_assertion,
).acquire()
return CopilotClient(connection_settings, token)
View on GitHub (pinned to c028a0c7dc)
Solutions
- Set APP_CLIENT_ID and TENANT_ID in the environment or .env file before calling create_client().
- Pass them explicitly: create_client(app_client_id=..., tenant_id=...).
- Verify env_file_path points to the correct .env file and that values are uncommented.
- 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
- Always set APP_CLIENT_ID and TENANT_ID in the environment or .env file.
- Pass them explicitly to create_client() to fail fast with clear errors.
- Validate env vars at application startup before any agent construction.
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
- Copilot Studio SERVICE authentication is not available yet.
- Failed to create Copilot Studio Agent settings: {exc}
- No IExternalKernelProcessMessageChannel found, need at least
- AllowedCallersClaimsValidator: config object cannot be None.
- "{self.config_key}" not found in configuration.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/be7e9ee8e3fd3f28.
Report an issue: GitHub.