fix(aws): nest endpointingSensitivity under turnDetectionConfiguration for Nova Sonic 2#6201
fix(aws): nest endpointingSensitivity under turnDetectionConfiguration for Nova Sonic 2#6201St-Luciferr wants to merge 1 commit into
Conversation
β¦n for Nova Sonic 2
| class TestSessionStartTurnDetection: | ||
| """Model-aware serialization of the turn-detection setting.""" |
There was a problem hiding this comment.
π‘ Test module missing mandatory pytestmark category marker
AGENTS.md mandates that every test module declares a category marker (pytestmark = pytest.mark.unit, etc.): "Adding a test: give the new module a category marker (pytestmark = pytest.mark.unit, etc.) β collection fails with a hint if it lacks one." The new test file test_nova_sonic_turn_detection.py has no pytestmark declaration. This is a pure unit test (no network/credentials needed) and should be marked pytest.mark.unit.
Prompt for agents
Add a module-level pytestmark to the test file. Since this test is a fast, hermetic unit test with no external dependencies (it even mocks out the AWS SDK), it should be marked as a unit test.
Add the following near the top of the file (after the imports, before the helper function):
import pytest
pytestmark = pytest.mark.unit
This satisfies the AGENTS.md rule requiring all test modules to declare a category marker.
Was this helpful? React with π or π to provide feedback.
| if self._nova_sonic_2 and endpointing_sensitivity is not None: | ||
| session_start = SessionStart( | ||
| inferenceConfiguration=inference, | ||
| turnDetectionConfiguration=TurnDetectionConfiguration( | ||
| endpointingSensitivity=endpointing_sensitivity | ||
| ), | ||
| ) | ||
| else: | ||
| session_start = SessionStart( | ||
| inferenceConfiguration=inference, | ||
| endpointingSensitivity=endpointing_sensitivity, | ||
| ) |
There was a problem hiding this comment.
π© Nova Sonic 2 with endpointing_sensitivity=None falls through to the legacy code path
When self._nova_sonic_2 is True but endpointing_sensitivity is None (line 382), the code falls to the else branch which sets endpointingSensitivity=None on SessionStart. With exclude_none=True, both endpointingSensitivity and turnDetectionConfiguration will be excluded from the JSON, resulting in a session start with no turn detection config at all. This is likely the intended behavior for disabling turn detection, but it's worth confirming with the Nova Sonic 2 API docs that omitting both fields is valid and doesn't cause a ValidationException.
Was this helpful? React with π or π to provide feedback.
Summary
Nova Sonic 2 (
amazon.nova-2-sonic-v1:0) rejects thesessionStartevent withValidationException: Invalid input requestbecause the plugin emits theturn-detection setting as a flat
endpointingSensitivityfield β the legacyNova Sonic 1 shape. Nova 2 requires it nested under
turnDetectionConfiguration(AWS docs).
This breaks every Nova Sonic 2 session at startup and cascades into
speech not done in time after interruptionand session shutdown.Changes
TurnDetectionConfigurationmodel and aturnDetectionConfigurationfield on
SessionStart.SonicEventBuilderserialization model-aware: Nova Sonic 2 β nestedturnDetectionConfiguration; Nova Sonic 1 (amazon.nova-sonic-v1:0) β legacyflat
endpointingSensitivity(no regression). Detection uses a substringmatch (
"nova-2-sonic" in model) so cross-region inference-profile ids suchas
us.amazon.nova-2-sonic-v1:0are handled correctly.SonicEventBuilderconstruction sites,including the session reconnect/restart path β otherwise a reconnected
Nova Sonic 1 session would fall back to the default model id and wrongly emit
the nested form.
sessionStartevent withexclude_none=Trueso only therelevant field is emitted.
Behavior notes
through 1.3.x), so this is an AWS-side validation tightening, not a recent
plugin regression. On Nova Sonic 2 the flat field was previously silently
ignored, so
turn_detection=...was effectively a no-op there β it nowactually applies.
Testing
livekit-plugins/livekit-plugins-aws/tests/test_nova_sonic_turn_detection.py:turnDetectionConfiguration.endpointingSensitivity,no flat field.
endpointingSensitivity, no nested field.us.amazon.nova-2-sonic-v1:0) β nested form.make checkpasses (ruff format, ruff lint, mypy).closes Nova Sonic 2 sessionStart rejected: endpointingSensitivity must be nested under turnDetectionConfigurationΒ #6200