Skip to content

Conversation

@xitzhang
Copy link
Member

Description

Please add an informative description that covers that changes made by the pull request and link all relevant issues.

If an SDK is being regenerated based on a new API spec, a link to the pull request containing these API spec changes should be included above.

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

Copilot AI review requested due to automatic review settings January 10, 2026 03:11
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 adds the NoTurnDetection feature to allow manual turn-taking control in VoiceLive conversations, along with significant improvements to serialization safety and model handling.

Changes:

  • Added NoTurnDetection class and TurnDetectionType.NONE enum to support client-managed conversation flow without automatic turn detection
  • Replaced unsafe eval() usage with explicit type checking in serialization/deserialization for improved security
  • Enhanced model serialization with support for delimited string arrays (pipe, space, comma, newline formats)
  • Fixed mutable type deserialization to properly track changes in model objects
  • Updated package to beta status with updated azure-core dependency

Reviewed changes

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

Show a summary per file
File Description
sdk/ai/azure-ai-voicelive/azure/ai/voicelive/models/_models.py Added NoTurnDetection class and updated TurnDetection base class documentation to include the new subclass
sdk/ai/azure-ai-voicelive/azure/ai/voicelive/models/_enums.py Added TurnDetectionType.NONE enum value for no turn detection mode
sdk/ai/azure-ai-voicelive/azure/ai/voicelive/models/init.py Exported NoTurnDetection class in public API
sdk/ai/azure-ai-voicelive/tests/test_live_realtime_service.py Updated test to use NoTurnDetection() instead of dictionary-based turn detection configuration
sdk/ai/azure-ai-voicelive/samples/async_mcp_sample.py Code formatting improvements (whitespace, line breaks)
sdk/ai/azure-ai-voicelive/pyproject.toml Updated development status to Beta and increased azure-core minimum version to 1.36.0
sdk/ai/azure-ai-voicelive/azure/ai/voicelive/_version.py Updated version to 1.2.0b3
sdk/ai/azure-ai-voicelive/azure/ai/voicelive/_utils/serialization.py Replaced eval() with explicit type checking for security and added error handling
sdk/ai/azure-ai-voicelive/azure/ai/voicelive/_utils/model_base.py Added array encoding support and improved mutable type deserialization caching
sdk/ai/azure-ai-voicelive/apiview-properties.json Added NoTurnDetection to API view mappings
sdk/ai/azure-ai-voicelive/CHANGELOG.md Updated changelog for 1.2.0b3 release with feature descriptions and bug fixes

Comment on lines +174 to +188
_ARRAY_ENCODE_MAPPING = {
"pipeDelimited": "|",
"spaceDelimited": " ",
"commaDelimited": ",",
"newlineDelimited": "\n",
}


def _deserialize_array_encoded(delimit: str, attr):
if isinstance(attr, str):
if attr == "":
return []
return attr.split(delimit)
return attr

Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The new array encoding/decoding functionality (lines 174-188, 330-334, 532-534, 819-829) lacks test coverage. Since the repository has comprehensive test coverage for serialization (test_unit_serialization.py), tests should be added for the new delimited array formats (pipe, space, comma, newline) to ensure proper encoding and decoding.

Copilot uses AI. Check for mistakes.
Comment on lines 372 to 406
def __getitem__(self, key: str) -> typing.Any:
# If this key has been deserialized (for mutable types), we need to handle serialization
if hasattr(self, "_attr_to_rest_field"):
cache_attr = f"_deserialized_{key}"
if hasattr(self, cache_attr):
rf = _get_rest_field(getattr(self, "_attr_to_rest_field"), key)
if rf:
value = self._data.get(key)
if isinstance(value, (dict, list, set)):
# For mutable types, serialize and return
# But also update _data with serialized form and clear flag
# so mutations via this returned value affect _data
serialized = _serialize(value, rf._format)
# If serialized form is same type (no transformation needed),
# return _data directly so mutations work
if isinstance(serialized, type(value)) and serialized == value:
return self._data.get(key)
# Otherwise return serialized copy and clear flag
try:
object.__delattr__(self, cache_attr)
except AttributeError:
pass
# Store serialized form back
self._data[key] = serialized
return serialized
return self._data.__getitem__(key)

def __setitem__(self, key: str, value: typing.Any) -> None:
# Clear any cached deserialized value when setting through dictionary access
cache_attr = f"_deserialized_{key}"
try:
object.__delattr__(self, cache_attr)
except AttributeError:
pass
self._data.__setitem__(key, value)
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The new mutable type deserialization caching mechanism (lines 372-406, 1073-1106) lacks test coverage. Since the repository has comprehensive test coverage for deserialization functionality, tests should be added to verify that mutations to deserialized mutable types (dict, list, set) are properly tracked and reflected in the model's _data.

Copilot uses AI. Check for mistakes.
Comment on lines +831 to +837
if data_type == "int":
return int(data)
if data_type == "float":
return float(data)
if data_type == "bool":
return bool(data)
raise TypeError("Unknown basic data type: {}".format(data_type))
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The replacement of eval() with explicit type checking (lines 831-837) lacks test coverage for the new error path. Since the repository has comprehensive test coverage for serialization, add tests to verify that calling serialize_basic with unsupported data types (not str, int, float, bool) raises a TypeError with an appropriate error message.

Copilot uses AI. Check for mistakes.
Comment on lines +1793 to +1797
if data_type == "int":
return int(attr)
if data_type == "float":
return float(attr)
raise TypeError("Unknown basic data type: {}".format(data_type))
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The replacement of eval() with explicit type checking (lines 1793-1797) lacks test coverage for the new error path. Since the repository has comprehensive test coverage for deserialization, add tests to verify that calling deserialize_basic with unsupported data types (not str, int, float, bool) raises a TypeError with an appropriate error message.

Copilot uses AI. Check for mistakes.
):
# encoded string may be deserialized to sequence
return deserializer(obj)
except: # pylint: disable=bare-except
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

Bare except clause catches all exceptions without discrimination, which can hide unexpected errors and make debugging difficult. Replace with specific exception types (e.g., AttributeError, TypeError) that might be raised when checking the deserializer structure.

Suggested change
except: # pylint: disable=bare-except
except (AttributeError, TypeError, IndexError):

Copilot uses AI. Check for mistakes.
"""No turn detection - client manages turn taking.
:ivar type: Required.
:vartype type: str or ~azure.ai.voicelive.models.NONE
Copy link

Copilot AI Jan 10, 2026

Choose a reason for hiding this comment

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

The documentation reference uses "~azure.ai.voicelive.models.NONE" which appears to be incorrect. It should reference the TurnDetectionType.NONE enum value properly, similar to how other models reference their types (e.g., using "str or ~azure.ai.voicelive.models.TurnDetectionType").

Suggested change
:vartype type: str or ~azure.ai.voicelive.models.NONE
:vartype type: str or ~azure.ai.voicelive.models.TurnDetectionType

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

API Change Check

APIView identified API level changes in this PR and created the following API reviews

azure-ai-voicelive

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants