microsoft.opentelemetry.a365.runtime.utility module
Utility functions for Microsoft Agent 365 runtime operations.
This module provides utility functions for token handling, agent identity resolution, and other common runtime operations.
- class microsoft.opentelemetry.a365.runtime.utility.Utility[source]
Bases:
objectUtility class providing common runtime operations for Agent 365.
This class contains static methods for token processing, agent identity resolution, and other utility functions used across the Agent 365 runtime.
- static get_app_id_from_token(token)[source]
Decodes the current token and retrieves the App ID (appid or azp claim).
WARNING: NO SIGNATURE VERIFICATION - This method uses jwt.decode() which does NOT verify the token signature. The token claims can be spoofed by malicious actors. This method is ONLY suitable for logging, analytics, and diagnostics purposes. Do NOT use the returned value for authorization, access control, or security decisions.
Note: Returns a default GUID (‘00000000-0000-0000-0000-000000000000’) for empty tokens for backward compatibility with callers that expect a valid-looking GUID. For agent identification where empty string is preferred, use get_agent_id_from_token().
- static get_agent_id_from_token(token)[source]
Decodes the token and retrieves the best available agent identifier. Checks claims in priority order: xms_par_app_azp (agent blueprint ID) > appid > azp.
WARNING: NO SIGNATURE VERIFICATION - This method uses jwt.decode() which does NOT verify the token signature. The token claims can be spoofed by malicious actors. This method is ONLY suitable for logging, analytics, and diagnostics purposes. Do NOT use the returned value for authorization, access control, or security decisions.
Note: Returns empty string for empty/missing tokens (unlike get_app_id_from_token() which returns a default GUID). This allows callers to omit headers when no identifier is available.
- static resolve_agent_identity(context, auth_token)[source]
Resolves the agent identity from the turn context or auth token.
- Parameters:
- Returns:
- The agent identity (App ID). Returns the agentic instance ID if the
request is agentic, otherwise returns the App ID from the auth token.
- Return type:
- static get_user_agent_header(orchestrator=None)[source]
Generates a User-Agent header string for SDK requests.