Skip to content

feat: adds support for speak fallback#548

Merged
jpvajda merged 5 commits into
mainfrom
feat/agent-fallbacks
Jul 11, 2025
Merged

feat: adds support for speak fallback#548
jpvajda merged 5 commits into
mainfrom
feat/agent-fallbacks

Conversation

@jpvajda

@jpvajda jpvajda commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Types of changes

Agent speak now supports:

  • Single provider (backward compatible): {"provider": {...}}
  • Array providers (fallback): [{"provider": {...}}, {"provider": {...}}]
  • README: Shows both single and dual provider examples
  • Added a dedicated Agent example: showing just two providers (realistic scenario)
  • ** kept existing agent examples using single provider (no complexity)
  • Dedicated fallback unit test:
  • a dedicate unit test for this functionality.

What types of changes does your code introduce to the community Python SDK?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update or tests (if none of the other choices apply)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have read the CONTRIBUTING doc
  • I have lint'ed all of my code using repo standards
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Summary by CodeRabbit

  • New Features

    • Added support for configuring multiple Text-to-Speech (TTS) providers with automatic fallback for voice agents.
  • Documentation

    • Updated the README with an example demonstrating the new multi-provider TTS configuration and fallback behavior.
  • Tests

    • Introduced comprehensive tests to verify single and multiple TTS provider configurations, including serialization and deserialization for both formats.

@coderabbitai

coderabbitai Bot commented Jul 1, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes introduce support for configuring multiple Text-to-Speech (TTS) providers with fallback in the agent's "speak" configuration, updating both the backend data models and the README usage example. Comprehensive unit tests are added to verify correct handling, serialization, and deserialization of both single and multiple provider configurations.

Changes

File(s) Change Summary
README.md Updated example to show configuring multiple TTS providers with fallback using a list of Speak instances.
deepgram/clients/agent/v1/websocket/options.py Modified Agent and UpdateSpeakOptions classes: speak now accepts single or list of Speak; added __post_init__ methods; updated __getitem__ to handle both cases.
tests/unit_test/test_unit_agent_speak_provider.py Added new tests for single and multiple provider support, including serialization, deserialization, and backward compatibility.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AgentOptions
    participant Speak
    participant Provider

    User->>AgentOptions: Configure agent with speak (single or list)
    AgentOptions->>AgentOptions: __post_init__ (normalize speak data)
    AgentOptions->>Speak: Instantiate Speak object(s)
    Speak->>Provider: Set provider attributes
    User->>AgentOptions: Serialize/deserialize configuration
    AgentOptions->>Speak: (If needed) Convert dict/list to Speak object(s)
    Note over AgentOptions: AgentOptions now supports both single and multiple Speak providers
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between edc87f3 and dfd5a6f.

📒 Files selected for processing (1)
  • README.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Check shell
  • GitHub Check: Check static
  • GitHub Check: Unit Tests
✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in a Comment
  • Commit Unit Tests in branch feat/agent-fallbacks

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jpvajda
jpvajda requested a review from lukeocodes July 1, 2025 23:54
Comment thread README.md Outdated
Comment thread examples/agent/fallback_tts/main.py Outdated
Comment thread tests/unit_test/test_unit_agent_speak_provider.py

@coderabbitai coderabbitai 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.

Actionable comments posted: 0

🧹 Nitpick comments (1)
tests/unit_test/test_unit_agent_speak_provider.py (1)

7-8: Remove unused imports for cleaner code.

The json and pytest imports are not used in this test file and can be removed to improve code cleanliness.

-import json
-import pytest
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1200c83 and e34f45a.

📒 Files selected for processing (4)
  • README.md (2 hunks)
  • deepgram/clients/agent/v1/websocket/options.py (2 hunks)
  • examples/agent/fallback_tts/main.py (1 hunks)
  • tests/unit_test/test_unit_agent_speak_provider.py (1 hunks)
🧰 Additional context used
🧠 Learnings (5)
📓 Common learnings
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/response.py:48-209
Timestamp: 2024-10-09T02:19:48.728Z
Learning: User dvonthenen prefers to defer certain suggestions, specifically regarding error handling and documentation enhancements in new data classes of `deepgram/clients/speak/v1/response.py`, and may revisit them later.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#424
File: deepgram/clients/speak/v1/response.py:48-209
Timestamp: 2024-06-27T00:06:23.128Z
Learning: User dvonthenen prefers to defer certain suggestions, specifically regarding error handling and documentation enhancements in new data classes of `deepgram/clients/speak/v1/response.py`, and may revisit them later.
README.md (9)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:16-17
Timestamp: 2024-10-18T00:30:20.224Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the hardcoded values for `AUDIO_FILE` and `TTS_TEXT` are intentional and should remain as is.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#468
File: examples/text-to-speech/websocket/complete/main.py:26-30
Timestamp: 2024-09-27T15:21:34.197Z
Learning: In `examples/text-to-speech/websocket/complete/main.py`, commented-out options like `auto_flush_speak_delta` and `verbose` are intentional in examples and should not be flagged in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/rest/options.py:12-12
Timestamp: 2024-10-09T02:19:46.087Z
Learning: Unused imports in `deepgram/clients/listen/v1/rest/options.py` are retained to maintain backwards compatibility.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/rest/options.py:12-12
Timestamp: 2024-07-01T19:12:36.972Z
Learning: Unused imports in `deepgram/clients/listen/v1/rest/options.py` are retained to maintain backwards compatibility.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/__init__.py:6-6
Timestamp: 2024-10-09T02:19:46.086Z
Learning: Imports for DeepgramClientOptions and ClientOptionsFromEnv in deepgram/clients/listen/__init__.py should not be flagged as unused in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/__init__.py:6-6
Timestamp: 2024-07-01T18:18:02.415Z
Learning: Imports for DeepgramClientOptions and ClientOptionsFromEnv in deepgram/clients/listen/__init__.py should not be flagged as unused in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: deepgram/clients/speak/v1/websocket/async_client.py:643-646
Timestamp: 2024-10-18T00:29:32.961Z
Learning: In `deepgram/clients/speak/v1/websocket/async_client.py`, the double call to `self._speaker.finish()` in the `finish` method of the `AsyncSpeakWSClient` class is intentional and required for proper cleanup.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/simple/main.py:41-50
Timestamp: 2024-10-18T00:25:58.316Z
Learning: In the `examples/text-to-speech/websocket/simple/main.py` file, the code is intended as a simple example and may include unused handlers or placeholder code meant for illustration purposes.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:52-56
Timestamp: 2024-10-18T00:30:04.220Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the code is intended as an example demonstrating functionality, and refactoring suggestions may not be necessary.
tests/unit_test/test_unit_agent_speak_provider.py (1)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#468
File: examples/text-to-speech/websocket/complete/main.py:26-30
Timestamp: 2024-09-27T15:21:34.197Z
Learning: In `examples/text-to-speech/websocket/complete/main.py`, commented-out options like `auto_flush_speak_delta` and `verbose` are intentional in examples and should not be flagged in reviews.
examples/agent/fallback_tts/main.py (10)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/simple/main.py:41-50
Timestamp: 2024-10-18T00:25:58.316Z
Learning: In the `examples/text-to-speech/websocket/simple/main.py` file, the code is intended as a simple example and may include unused handlers or placeholder code meant for illustration purposes.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:52-56
Timestamp: 2024-10-18T00:30:04.220Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the code is intended as an example demonstrating functionality, and refactoring suggestions may not be necessary.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/simple/main.py:101-101
Timestamp: 2024-10-18T00:26:33.968Z
Learning: In the `examples/text-to-speech/websocket/simple/main.py` file, it's acceptable for `wait_for_complete()` to lack exception handling, as it is intended to demonstrate functionality in an example context.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#468
File: examples/text-to-speech/websocket/complete/main.py:26-30
Timestamp: 2024-09-27T15:21:34.197Z
Learning: In `examples/text-to-speech/websocket/complete/main.py`, commented-out options like `auto_flush_speak_delta` and `verbose` are intentional in examples and should not be flagged in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:16-17
Timestamp: 2024-10-18T00:30:20.224Z
Learning: In `examples/text-to-speech/websocket/output_to_wav/main.py`, the hardcoded values for `AUDIO_FILE` and `TTS_TEXT` are intentional and should remain as is.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/text-to-speech/websocket/output_to_wav/main.py:38-41
Timestamp: 2024-10-18T00:30:01.884Z
Learning: In the `examples/text-to-speech/websocket/output_to_wav/main.py` file, the code is intended as a simple example, and additional error handling for file operations is not required.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#472
File: examples/speech-to-text/websocket/replay/main.py:78-80
Timestamp: 2024-10-18T16:20:17.742Z
Learning: In the `examples` directory of the Deepgram Python SDK, code is intended as illustrative examples and doesn't require production-level error handling.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/websocket/__init__.py:8-8
Timestamp: 2024-10-09T02:19:46.086Z
Learning: Unused imports in `deepgram/clients/listen/v1/websocket/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/websocket/__init__.py:8-8
Timestamp: 2024-07-01T19:21:39.778Z
Learning: Unused imports in `deepgram/clients/listen/v1/websocket/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/__init__.py:16-19
Timestamp: 2024-07-01T19:12:57.715Z
Learning: Unused imports in `deepgram/clients/speak/__init__.py` are retained for backward compatibility and should not be flagged for removal in reviews.
deepgram/clients/agent/v1/websocket/options.py (13)
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#431
File: deepgram/clients/listen/v1/websocket/client.py:30-30
Timestamp: 2024-10-09T02:19:46.087Z
Learning: The `LiveOptions` import in `deepgram/clients/listen/v1/websocket/client.py` is intentionally present for future use and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#431
File: deepgram/clients/listen/v1/websocket/client.py:30-30
Timestamp: 2024-07-11T14:10:17.231Z
Learning: The `LiveOptions` import in `deepgram/clients/listen/v1/websocket/client.py` is intentionally present for future use and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/rest/options.py:12-12
Timestamp: 2024-10-09T02:19:46.087Z
Learning: Unused imports in `deepgram/clients/listen/v1/rest/options.py` are retained to maintain backwards compatibility.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/rest/options.py:12-12
Timestamp: 2024-07-01T19:12:36.972Z
Learning: Unused imports in `deepgram/clients/listen/v1/rest/options.py` are retained to maintain backwards compatibility.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/websocket/__init__.py:8-8
Timestamp: 2024-10-09T02:19:46.086Z
Learning: Unused imports in `deepgram/clients/listen/v1/websocket/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/listen/v1/websocket/__init__.py:8-8
Timestamp: 2024-07-01T19:21:39.778Z
Learning: Unused imports in `deepgram/clients/listen/v1/websocket/__init__.py` are retained to maintain backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#468
File: examples/text-to-speech/websocket/complete/main.py:26-30
Timestamp: 2024-09-27T15:21:34.197Z
Learning: In `examples/text-to-speech/websocket/complete/main.py`, commented-out options like `auto_flush_speak_delta` and `verbose` are intentional in examples and should not be flagged in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/__init__.py:16-19
Timestamp: 2024-07-01T19:12:57.715Z
Learning: Unused imports in `deepgram/clients/speak/__init__.py` are retained for backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/__init__.py:16-19
Timestamp: 2024-10-09T02:19:46.087Z
Learning: Unused imports in `deepgram/clients/speak/__init__.py` are retained for backward compatibility and should not be flagged for removal in reviews.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/v1/websocket/response.py:23-30
Timestamp: 2024-07-01T19:12:00.190Z
Learning: When using the `dataclasses.field` with default values in the `deepgram/clients/speak/v1/websocket/response.py`, avoid using mutable default arguments. Instead, use `field(default_factory=...)`.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/response.py:179-194
Timestamp: 2024-08-14T19:04:32.758Z
Learning: The conversion of lists to specific object types in the `__getitem__` method is required by `dataclasses_json` for serialization/deserialization purposes, even if they are already lists of those objects.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#445
File: deepgram/clients/manage/v1/response.py:179-194
Timestamp: 2024-10-09T02:19:46.086Z
Learning: The conversion of lists to specific object types in the `__getitem__` method is required by `dataclasses_json` for serialization/deserialization purposes, even if they are already lists of those objects.
Learnt from: dvonthenen
PR: deepgram/deepgram-python-sdk#426
File: deepgram/clients/speak/v1/websocket/response.py:23-30
Timestamp: 2024-10-09T02:19:48.728Z
Learning: When using the `dataclasses.field` with default values in the `deepgram/clients/speak/v1/websocket/response.py`, avoid using mutable default arguments. Instead, use `field(default_factory=...)`.
🧬 Code Graph Analysis (2)
tests/unit_test/test_unit_agent_speak_provider.py (1)
deepgram/clients/agent/v1/websocket/options.py (7)
  • SettingsOptions (368-398)
  • UpdateSpeakOptions (418-436)
  • Agent (254-322)
  • Speak (219-250)
  • Provider (72-85)
  • Endpoint (89-106)
  • Header (21-27)
deepgram/clients/agent/v1/websocket/options.py (1)
deepgram/client.py (2)
  • speak (503-507)
  • listen (489-493)
🪛 Flake8 (7.2.0)
tests/unit_test/test_unit_agent_speak_provider.py

[error] 7-7: 'json' imported but unused

(F401)


[error] 8-8: 'pytest' imported but unused

(F401)


[error] 9-9: 'deepgram.clients.agent.v1.websocket.options.Agent' imported but unused

(F401)


[error] 9-9: 'deepgram.clients.agent.v1.websocket.options.Provider' imported but unused

(F401)

🔇 Additional comments (9)
deepgram/clients/agent/v1/websocket/options.py (4)

276-276: LGTM! Well-designed type annotation change.

The Union[Speak, List[Speak]] type properly supports both single provider (backward compatible) and multiple provider (new fallback feature) configurations while maintaining the existing default behavior.


281-310: Excellent implementation of polymorphic type conversion.

The __post_init__ method correctly handles all scenarios:

  • List of dicts → List of Speak objects
  • Single dict → Single Speak object
  • Existing Speak objects remain unchanged

The pattern is consistent with existing listen and think attribute handling, ensuring maintainability.


317-322: Correct deserialization logic for polymorphic speak attribute.

The updated __getitem__ method properly handles both list and single dict formats during deserialization, maintaining consistency with the __post_init__ conversion logic.


424-436: Consistent implementation across option classes.

The UpdateSpeakOptions class correctly mirrors the Agent class implementation, enabling dynamic speak configuration updates with both single and multiple provider formats. The code consistency is excellent.

README.md (1)

253-310: Excellent documentation with clear examples.

The README effectively demonstrates both single and multiple TTS provider configurations:

  • Maintains backward compatibility by showing existing patterns
  • Provides realistic, complete examples with proper endpoint and header configuration
  • Clear section organization with descriptive headings
  • Educational value is excellent for developers implementing fallback TTS
examples/agent/fallback_tts/main.py (3)

1-27: Well-structured example with clear documentation.

The file header and imports are properly organized with excellent documentation explaining the purpose and scope of the fallback TTS feature. The global warning variable pattern is acceptable for example code.


102-143: Realistic and educational provider configuration.

The TTS provider setup demonstrates best practices:

  • Primary/fallback provider strategy with different types (Deepgram/OpenAI)
  • Proper custom endpoint configuration with authentication headers
  • Realistic model selections and voice parameters
  • Clear explanatory comments and console output

145-162: Proper connection management and user interaction.

The WebSocket connection lifecycle is correctly managed with comprehensive error handling and clear user feedback. The example maintains simplicity while demonstrating all necessary aspects of the fallback TTS feature.

tests/unit_test/test_unit_agent_speak_provider.py (1)

20-359: Comprehensive test coverage for multi-provider functionality.

The test suite excellently covers all aspects of the new feature:

  • Backward compatibility: Single provider format tests ensure existing code continues working
  • New functionality: Array provider tests validate multi-provider configurations
  • Data integrity: Round-trip serialization/deserialization tests ensure no data loss
  • Edge cases: Custom attributes, multiple endpoints, and mixed configurations
  • Dynamic updates: UpdateSpeakOptions testing for runtime configuration changes

The test organization is logical with clear class separation by functionality and descriptive test method names.

@jpvajda jpvajda changed the title Feat/agent fallbacks feat: agent fallbacks Jul 3, 2025
@jpvajda jpvajda changed the title feat: agent fallbacks feat: adds support for agent fallbacks Jul 3, 2025
@jpvajda jpvajda changed the title feat: adds support for agent fallbacks feat: adds support for speak fallbacks Jul 3, 2025
@jpvajda jpvajda changed the title feat: adds support for speak fallbacks feat: adds support for speak fallback Jul 3, 2025
@jpvajda

jpvajda commented Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

I built a simple test app locally to test this out, everything looks good. ✅

🎉 Excellent! All tests passed successfully!

The test app worked perfectly and validated all the agent speak provider functionality:

Test Results Summary:

All 6 tests PASSED:

  1. Serialization Roundtrip - Confirms data can be serialized and deserialized correctly
  2. Single Deepgram Provider - Tests the traditional single provider format
  3. Array Providers (Deepgram + OpenAI) - Tests the new array provider format with both providers
  4. UpdateSpeakOptions - Tests dynamic provider updates during runtime
  5. Arbitrary Provider Attributes - Confirms custom attributes are preserved
  6. Environment Variable Substitution - Validates API key template handling

Key Validations:

  • API Keys detected: Both DEEPGRAM_API_KEY and OPENAI_API_KEY were found
  • Single provider format: Deepgram provider configured correctly
  • Array provider format: Multiple providers (Deepgram + OpenAI) work together
  • Serialization: All configurations serialize/deserialize properly
  • Environment variables: Template substitution works ({{OPENAI_API_KEY}})
  • Dynamic updates: UpdateSpeakOptions can change providers mid-conversation
  • Custom attributes: Arbitrary provider attributes are preserved

Future Steps: The agent speak provider functionality is now fully tested and validated. The code works correctly beyond the unit tests, supporting both single and array provider formats, proper API key handling, and dynamic provider updates. You can now confidently use this functionality in production applications.

@jpvajda
jpvajda requested a review from naomi-lgbt July 10, 2025 13:17

@lukeocodes lukeocodes 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.

I've reviewed this again. I think it is possible this is technically breaking, despite it supporting the existing interface

I have requested some input from the Python community. I will update again when I know more.

@lukeocodes lukeocodes 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.

The interface changing would technically break type-checking if it was built to be used in that way.

But seeing as this is our internal types, and the tests specifically test the old and new way of defining providers, this is a good change.

LGTM.

@jpvajda
jpvajda merged commit cab41fa into main Jul 11, 2025
6 checks passed
@jpvajda
jpvajda deleted the feat/agent-fallbacks branch July 11, 2025 14:20
@coderabbitai coderabbitai Bot mentioned this pull request Jul 14, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Aug 2, 2025
8 tasks
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.

3 participants