Skip to content

Conversation

@JinLee794
Copy link
Collaborator

This pull request includes several updates across configuration files, environment samples, backend initialization, and code cleanup. The main focus is on improving environment variable naming consistency (especially for Azure Voice Live), refining backend initialization and logging, enhancing call connection ID handling, and removing demo and obsolete files. Below are the most important changes grouped by theme.

Environment and Configuration Updates:

  • Standardized Azure Voice Live environment variable names in .env.sample and voice_config.py for consistency, using AZURE_SPEECH_ENDPOINT and AZURE_SPEECH_KEY instead of legacy names. Also added AI_FOUNDRY_AGENT_ID to .env.sample. [1] [2]
  • Ensured BASE_URL in infrastructure.py has no trailing slash for consistency in URL handling.
  • Updated deployment documentation (DeploymentGuide.md) to use model_deployments instead of openai_models for model configuration. [1] [2]

Backend Initialization and Logging:

  • Improved Redis initialization logging in main.py to indicate cluster support and retry logic. Also switched AOAI pool initialization timing to use time.perf_counter() for more accurate performance measurement. [1] [2]
  • Removed commented-out code related to Voice Live pool initialization in main.py for clarity.

Call Connection ID Handling:

  • Refactored ThreadBridge and RouteTurnThread in acs_media_lifecycle.py to consistently pass and store call_connection_id, improving call tracking and debugging. [1] [2] [3] [4]

System Dependencies and DevOps:

  • Added installation of portaudio19-dev as a system dependency in the docs.yml GitHub Actions workflow to support audio features.
  • Removed the detailed README.md from devops/scripts/, likely to reduce duplication or outdated documentation.

Code Cleanup:

  • Deleted the demo event processor file demo.py and the consolidated settings file app_settings_new.py from the backend, removing obsolete or redundant code. [1] [2]

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a cleanup of the codebase, focusing on consolidating VoiceLive parameters, standardizing environment variable names, improving backend initialization, and removing obsolete files. The main changes address configuration consistency, call connection ID handling, and general code organization.

  • Standardized Azure Voice Live environment variable names for consistency across configuration files
  • Enhanced backend initialization and logging with cluster support and performance improvements
  • Improved call connection ID handling across media lifecycle components
  • Removed obsolete demo files and consolidated settings

Reviewed Changes

Copilot reviewed 31 out of 40 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/ Converted async tests to synchronous with manual event loop execution for better pytest compatibility
src/redis/manager.py Added comprehensive cluster support with automatic failover and improved error handling
infra/terraform/ Updated pool size defaults and fixed module references for production deployment
apps/rtagent/backend/ Consolidated VoiceLive configuration and improved call connection ID tracking
.env.sample Added AI Foundry agent ID and standardized Azure Speech variable names

from unittest.mock import AsyncMock, MagicMock, patch
from fastapi.testclient import TestClient

sys.modules.setdefault("sounddevice", MagicMock())
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

Consider moving the sounddevice mock setup to a conftest.py file or a test utility module. This pattern is repeated across multiple test files and would benefit from centralization to reduce code duplication and ensure consistent mocking behavior across all tests.

Suggested change
sys.modules.setdefault("sounddevice", MagicMock())
# sounddevice mock setup moved to conftest.py for centralization

Copilot uses AI. Check for mistakes.
Comment on lines +37 to +39
def run_async(coro):
"""Execute coroutine for pytest environments without asyncio plugin."""
return asyncio.run(coro)
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The run_async helper function is duplicated across multiple test files. Consider creating a shared test utility module to avoid code duplication and ensure consistent async test execution patterns.

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +102
assert mgr._remap_cluster_address(("51.8.10.248", 8501)) == (
"example.redis.local",
8501,
)
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The hardcoded IP address '51.8.10.248' appears to be a magic number. Consider using a constant or a more descriptive variable name to make the test intent clearer and easier to maintain.

Copilot uses AI. Check for mistakes.
attempts.append((self.host, self.port))

last_exc: Optional[Exception] = None
tried: set[tuple[str, Optional[int]]] = set()
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The type annotation set[tuple[str, Optional[int]]] uses the built-in set type which requires Python 3.9+. For better compatibility, consider using Set[Tuple[str, Optional[int]]] from the typing module, which is already imported.

Suggested change
tried: set[tuple[str, Optional[int]]] = set()
tried: Set[Tuple[str, Optional[int]]] = set()

Copilot uses AI. Check for mistakes.
description = "Size of the Azure OpenAI client pool for optimal performance"
type = number
default = 50
default = 5
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

[nitpick] The AOAI pool size has been reduced from 50 to 5. While this may be appropriate for development environments, ensure this default is suitable for production workloads. Consider documenting the rationale for this change or making it environment-dependent.

Suggested change
default = 5
# Default pool size is environment-dependent: use 5 for 'dev', 50 for other environments.
# Rationale: Lower pool size reduces resource usage in development, higher value is suitable for production workloads.
default = contains(["dev", "development"], lower(var.environment_name)) ? 5 : 50

Copilot uses AI. Check for mistakes.
Comment on lines +99 to +101
# AZURE_VOICE_LIVE_ENDPOINT = os.getenv("AZURE_VOICE_LIVE_ENDPOINT", "")
# AZURE_VOICE_API_KEY = os.getenv("AZURE_VOICE_API_KEY", "")
# AZURE_VOICE_LIVE_MODEL = os.getenv("AZURE_VOICE_LIVE_MODEL", "gpt-4o")
Copy link

Copilot AI Sep 28, 2025

Choose a reason for hiding this comment

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

The commented-out legacy environment variables should be removed rather than left as comments. If they need to be preserved for reference, consider documenting the migration in a separate documentation file or changelog.

Suggested change
# AZURE_VOICE_LIVE_ENDPOINT = os.getenv("AZURE_VOICE_LIVE_ENDPOINT", "")
# AZURE_VOICE_API_KEY = os.getenv("AZURE_VOICE_API_KEY", "")
# AZURE_VOICE_LIVE_MODEL = os.getenv("AZURE_VOICE_LIVE_MODEL", "gpt-4o")

Copilot uses AI. Check for mistakes.
@JinLee794 JinLee794 closed this Sep 29, 2025
@JinLee794 JinLee794 deleted the cleanup/pybackend branch October 17, 2025 16:37
pablosalvador10 added a commit that referenced this pull request Dec 19, 2025
feat: Implement TTS Streaming Latency Analysis and Optimization Plan
JinLee794 pushed a commit that referenced this pull request Dec 19, 2025
JinLee794 added a commit that referenced this pull request Dec 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants