Skip to content

Conversation

lukeocodes
Copy link
Contributor

@lukeocodes lukeocodes commented Jul 25, 2025

Proposed changes

The mip_opt_out field was incorrectly placed inside the agent object, but according to the Deepgram API specification, it should be at the root level of the Settings message payload.

This was causing the API to return: 'Error parsing client message. Check the agent.mip_opt_out field against the API spec.'

  • Moved mip_opt_out from Agent class to SettingsOptions class
  • Updated all unit tests to reference the new location
  • Verified serialization now matches API spec: mip_opt_out at $message.payload#/mip_opt_out

Types of changes

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 (except 1 line ❗ isn't linted)
  • 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

  • Refactor
    • The location of the mip_opt_out setting has changed; it is now configured directly in SettingsOptions rather than within Agent.
  • Tests
    • Updated tests to reflect the new placement of mip_opt_out, ensuring correct serialization and validation at the new location.
    • Removed tests related to mip_opt_out within Agent and added tests to confirm its removal.

The mip_opt_out field was incorrectly placed inside the agent object, but according to the Deepgram API specification, it should be at the root level of the Settings message payload.

This was causing the API to return: 'Error parsing client message. Check the agent.mip_opt_out field against the API spec.'

- Moved mip_opt_out from Agent class to SettingsOptions class
- Updated all unit tests to reference the new location
- Verified serialization now matches API spec: mip_opt_out at $message.payload#/mip_opt_out
@lukeocodes lukeocodes self-assigned this Jul 25, 2025
@lukeocodes lukeocodes added the bug Something isn't working label Jul 25, 2025
Copy link
Contributor

coderabbitai bot commented Jul 25, 2025

Walkthrough

The mip_opt_out field was moved from the Agent dataclass to the SettingsOptions dataclass in the agent WebSocket options module. All related tests were updated to reference and assert mip_opt_out at the root level of SettingsOptions instead of within Agent. No other logic or control flow changes occurred.

Changes

File(s) Change Summary
deepgram/clients/agent/v1/websocket/options.py Removed mip_opt_out from Agent and added it to SettingsOptions with same type/metadata.
tests/unit_test/test_unit_agent_mip_opt_out.py Refactored all tests to check mip_opt_out at SettingsOptions root; updated assertions, docstrings, and removed redundant tests.
tests/unit_test/test_unit_agent_tags.py Updated test to set and assert mip_opt_out at SettingsOptions root instead of under Agent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Pylint (3.3.7)
deepgram/clients/agent/v1/websocket/options.py
tests/unit_test/test_unit_agent_mip_opt_out.py
tests/unit_test/test_unit_agent_tags.py

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 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 d605248 and 442fc33.

📒 Files selected for processing (3)
  • deepgram/clients/agent/v1/websocket/options.py (1 hunks)
  • tests/unit_test/test_unit_agent_mip_opt_out.py (3 hunks)
  • tests/unit_test/test_unit_agent_tags.py (2 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: jpvajda
PR: deepgram/deepgram-python-sdk#558
File: deepgram/clients/agent/v1/websocket/options.py:274-276
Timestamp: 2025-07-21T15:36:29.068Z
Learning: In the Deepgram Python SDK, the pattern of using `Optional[bool]` with `default=False` (without exclude conditions) is intentionally used for API flexibility. This allows the API to accept various input types while maintaining consistent default behavior. The `experimental` field in `SettingsOptions` and `mip_opt_out` field in `Agent` both follow this pattern, where they always serialize to JSON and provide a consistent default value while allowing flexible input handling.
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#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#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.
tests/unit_test/test_unit_agent_mip_opt_out.py (1)

Learnt from: jpvajda
PR: #558
File: deepgram/clients/agent/v1/websocket/options.py:274-276
Timestamp: 2025-07-21T15:36:29.068Z
Learning: In the Deepgram Python SDK, the pattern of using Optional[bool] with default=False (without exclude conditions) is intentionally used for API flexibility. This allows the API to accept various input types while maintaining consistent default behavior. The experimental field in SettingsOptions and mip_opt_out field in Agent both follow this pattern, where they always serialize to JSON and provide a consistent default value while allowing flexible input handling.

tests/unit_test/test_unit_agent_tags.py (1)

Learnt from: jpvajda
PR: #558
File: deepgram/clients/agent/v1/websocket/options.py:274-276
Timestamp: 2025-07-21T15:36:29.068Z
Learning: In the Deepgram Python SDK, the pattern of using Optional[bool] with default=False (without exclude conditions) is intentionally used for API flexibility. This allows the API to accept various input types while maintaining consistent default behavior. The experimental field in SettingsOptions and mip_opt_out field in Agent both follow this pattern, where they always serialize to JSON and provide a consistent default value while allowing flexible input handling.

deepgram/clients/agent/v1/websocket/options.py (10)

Learnt from: jpvajda
PR: #558
File: deepgram/clients/agent/v1/websocket/options.py:274-276
Timestamp: 2025-07-21T15:36:29.068Z
Learning: In the Deepgram Python SDK, the pattern of using Optional[bool] with default=False (without exclude conditions) is intentionally used for API flexibility. This allows the API to accept various input types while maintaining consistent default behavior. The experimental field in SettingsOptions and mip_opt_out field in Agent both follow this pattern, where they always serialize to JSON and provide a consistent default value while allowing flexible input handling.

Learnt from: dvonthenen
PR: #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: #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: #431
File: deepgram/clients/listen/v1/websocket/async_client.py:30-30
Timestamp: 2024-07-11T14:10:24.647Z
Learning: The unused import LiveOptions in deepgram/clients/listen/v1/websocket/async_client.py is intentional and will be used in PR #432.

Learnt from: dvonthenen
PR: #431
File: deepgram/clients/listen/v1/websocket/async_client.py:30-30
Timestamp: 2024-10-09T02:19:46.087Z
Learning: The unused import LiveOptions in deepgram/clients/listen/v1/websocket/async_client.py is intentional and will be used in PR #432.

Learnt from: dvonthenen
PR: #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: #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: #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: #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: #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.

🧬 Code Graph Analysis (1)
tests/unit_test/test_unit_agent_mip_opt_out.py (2)
deepgram/clients/agent/v1/websocket/options.py (2)
  • SettingsOptions (346-379)
  • Agent (248-300)
deepgram/client.py (1)
  • agent (593-597)
🔇 Additional comments (7)
tests/unit_test/test_unit_agent_tags.py (1)

165-177: LGTM! Test correctly updated for mip_opt_out relocation.

The test has been properly updated to reflect the movement of mip_opt_out from the Agent class to the root level of SettingsOptions. The changes correctly:

  • Set mip_opt_out directly on the options object (line 165)
  • Assert the value at the root level (line 170)
  • Verify serialization places the field at the root level of the dictionary (line 177)

This aligns with the API specification requirement that mip_opt_out should be at $message.payload#/mip_opt_out.

deepgram/clients/agent/v1/websocket/options.py (1)

355-357: LGTM! Correct implementation of mip_opt_out relocation.

The mip_opt_out field has been properly moved to the root level of SettingsOptions class. The implementation correctly:

  • Uses Optional[bool] with default=False for API flexibility (consistent with retrieved learnings)
  • Applies the same metadata pattern with exclude=lambda f: f is None
  • Places the field at the root level to align with the Deepgram API specification requirement at $message.payload#/mip_opt_out

This fixes the API parsing error mentioned in the PR objectives.

tests/unit_test/test_unit_agent_mip_opt_out.py (5)

14-14: LGTM! Updated class docstring reflects the relocation.

The class docstring correctly indicates that mip_opt_out is now tested "at the root level of SettingsOptions" rather than within the Agent class.


20-21: LGTM! Test methods correctly updated for root-level access.

All test methods have been properly updated to access and assert mip_opt_out directly on the options object rather than through options.agent. This correctly reflects the field's new location at the root level of SettingsOptions.

Also applies to: 26-28, 33-35


46-48: LGTM! Serialization tests correctly validate root-level placement.

The serialization test assertions have been properly updated to verify that mip_opt_out appears at the root level of the serialized dictionary rather than nested under the "agent" key. This ensures compliance with the API specification requirement.

Also applies to: 59-61, 73-74


79-85: LGTM! Deserialization tests updated for root-level data structure.

The deserialization tests correctly expect mip_opt_out to be present at the root level of the input data structure, with the "agent" object remaining separate. This validates that the field can be properly reconstructed from API-compliant JSON payloads.

Also applies to: 88-94


155-159: Excellent addition! New test validates removal from Agent class.

This new test method provides important validation that mip_opt_out has been completely removed from the Agent class, preventing any confusion or accidental usage of the old location. This helps ensure a clean migration and prevents regression.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hotfix/move-mip-opt-out-to-root

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 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 merged commit eca802a into main Jul 25, 2025
8 checks passed
@jpvajda jpvajda deleted the hotfix/move-mip-opt-out-to-root branch July 25, 2025 20:21
@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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants