Skip to content

Expose TTS fallback controls and activation events (LKINF-495) - #7185

Open
russellmartin-livekit wants to merge 1 commit into
mainfrom
russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices
Open

Expose TTS fallback controls and activation events (LKINF-495)#7185
russellmartin-livekit wants to merge 1 commit into
mainfrom
russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices

Conversation

@russellmartin-livekit

@russellmartin-livekit russellmartin-livekit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add constructor-only disable_system_default_fallback and serialize opt-out even without customer fallback models
  • expose a typed fallback_activated event for regular and system-default fallback output
  • include the serving provider, model, voice, sanitized cause, and fallback type
  • normalize future causes and fallback types to unknown
  • ignore structurally malformed notices without interrupting audio
  • keep existing fallback-model payloads unchanged

Testing

  • uv run pytest tests/test_inference_tts_fallback.py tests/test_inference_tts_alignment.py
  • uv run ruff check livekit-agents/livekit/agents/inference/tts.py livekit-agents/livekit/agents/inference/__init__.py tests/test_inference_tts_fallback.py tests/test_inference_tts_alignment.py
  • uv run ruff format --check livekit-agents/livekit/agents/inference/tts.py livekit-agents/livekit/agents/inference/__init__.py tests/test_inference_tts_fallback.py tests/test_inference_tts_alignment.py
  • uv run --group typing mypy -p livekit.agents

Coordinated PRs

LKINF-495

@russellmartin-livekit
russellmartin-livekit force-pushed the russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices branch from e42ebb2 to e7a7dda Compare September 10, 2026 10:24
@russellmartin-livekit
russellmartin-livekit force-pushed the russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices branch 2 times, most recently from b1e0a4e to 11335c2 Compare September 10, 2026 12:38
@russellmartin-livekit
russellmartin-livekit marked this pull request as ready for review September 10, 2026 16:10
@russellmartin-livekit
russellmartin-livekit requested a review from a team as a code owner September 10, 2026 16:10

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@russellmartin-livekit
russellmartin-livekit force-pushed the russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices branch from 11335c2 to c0749e8 Compare September 10, 2026 16:54
@russellmartin-livekit russellmartin-livekit changed the title Expose TTS system fallback controls and notices (LKINF-495) Expose TTS fallback controls and activation events (LKINF-495) Sep 10, 2026
@russellmartin-livekit
russellmartin-livekit force-pushed the russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices branch 2 times, most recently from 6f2865d to 8cf9590 Compare September 10, 2026 17:48

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

This report is out of date. Scroll down for Devin Review's latest report on this PR.

Devin Review found 1 new potential issue.

Devin Review

Comment on lines +138 to +141
def _normalize_fallback_type(fallback_type: object) -> FallbackType:
if isinstance(fallback_type, str) and fallback_type in _FALLBACK_TYPES:
return cast(FallbackType, fallback_type)
return "unknown"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Malformed fallback notices emit events

A missing or non-string fallback_type becomes unknown instead of failing validation. Listeners receive an event when every other field is valid.

Learn more

Unknown string values represent future gateway enum members and can safely map to unknown. Missing values and non-string values are structurally invalid, but this helper maps those values to the same valid enum member. Pydantic therefore cannot reject the notice when its other fields are valid.

Example: A notice containing valid session_id, provider, model, voice, and cause fields but no fallback_type emits FallbackActivatedEvent(fallback_type="unknown"). The notice must instead be ignored while subsequent audio continues.

Recommended fix: Preserve validation failure for missing and non-string values while mapping only unrecognized strings to unknown. Add test cases for an absent value and a non-string value with all other required fields present.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@russellmartin-livekit
russellmartin-livekit force-pushed the russellmartin/lkinf-495-expose-tts-fallback-controls-and-notices branch from 8cf9590 to 6a0149e Compare September 11, 2026 09:55

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Devin Review

Comment on lines +797 to +800
except ValidationError as e:
logger.warning(
"ignoring invalid fallback activation notice",
extra={"session_id": data.get("session_id"), "error": str(e)},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟨 Validation errors bypass PII redaction

A malformed fallback notice logs str(e) under the unmarked error attribute. Rejected gateway values can reach logs without collector redaction.

Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

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.

1 participant