Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions sdk/ai/azure-ai-voicelive/samples/supervisor_agent_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
from typing import Union, Optional, cast
from concurrent.futures import ThreadPoolExecutor

from azure.identity.aio import AzureCliCredential, DefaultAzureCredential

Comment on lines +29 to +30
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The imports AzureKeyCredential and AsyncTokenCredential (lines 50-51) are no longer used after removing API key authentication support. These unused imports should be removed to keep the code clean. However, if API key support is restored (as recommended), these imports should remain.

Copilot uses AI. Check for mistakes.
# Audio processing imports
try:
import pyaudio
Expand Down Expand Up @@ -355,7 +357,7 @@ class AsyncSupervisorAgentClient:
def __init__(
self,
endpoint: str,
credential: Union[AzureKeyCredential, AsyncTokenCredential],
credential: Union[AzureCliCredential, DefaultAzureCredential],
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type annotation is too restrictive and inconsistent with the rest of the codebase. It should be Union[AzureKeyCredential, AsyncTokenCredential] to support both API key and token-based authentication methods. Other samples in this repository (async_function_calling_sample.py and basic_voice_assistant_async.py) use this more flexible type annotation, which allows users to choose their preferred authentication method.

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is better from azure.core.credentials_async import AsyncTokenCredential

model: str,
voice: str,
instructions: str,
Expand Down Expand Up @@ -541,21 +543,10 @@ async def _handle_event(self, event, connection) -> None:
async def main() -> None:
"""Main entry point for the supervisor agent sample."""
# Get credentials from environment variables
api_key = os.environ.get("AZURE_VOICELIVE_API_KEY")
endpoint = os.environ.get("AZURE_VOICELIVE_ENDPOINT", "wss://api.voicelive.com/v1")

if not api_key:
print("❌ Error: No AZURE_VOICELIVE_API_KEY provided")
print("Please set the AZURE_VOICELIVE_API_KEY environment variable.")
sys.exit(1)

# Option 1: API key authentication (simple, recommended for quick start)
credential: Union[AzureKeyCredential, AsyncTokenCredential] = AzureKeyCredential(api_key)

# Option 2: Async AAD authentication (requires azure-identity)
# Uncomment the lines below to use AAD authentication instead:
# from azure.identity.aio import AzureCliCredential, DefaultAzureCredential
# credential = AzureCliCredential()

credential = AzureCliCredential()
Comment on lines +548 to +549
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the credential to only AzureCliCredential removes flexibility for users. The sample should support multiple authentication methods like other samples in this repository. Consider either: (1) keeping the commented-out options to show users both API key and token credential choices, or (2) adding a command-line parameter like basic_voice_assistant_async.py does with --use-token-credential flag. This would make the sample more useful and consistent with other samples in the codebase.

Suggested change
credential = AzureCliCredential()
# Choose the authentication method you want to use:
#
# Option 1: Use DefaultAzureCredential (recommended for most applications)
# This will use environment variables, managed identity, Visual Studio Code, Azure CLI, etc.
# from azure.identity.aio import DefaultAzureCredential
# credential = DefaultAzureCredential()
#
# Option 2: Use AzureCliCredential (for local development with an authenticated Azure CLI session)
credential = AzureCliCredential()
#
# Option 3: Use API key authentication
# Set the AZURE_VOICELIVE_API_KEY environment variable with your key.
# from azure.core.credentials import AzureKeyCredential
# credential = AzureKeyCredential(os.environ["AZURE_VOICELIVE_API_KEY"])

Copilot uses AI. Check for mistakes.

# Create and run the supervisor agent client
client = AsyncSupervisorAgentClient(
Expand Down
Loading