Skip to content

Conversation

jpvajda
Copy link
Contributor

@jpvajda jpvajda commented Aug 1, 2025

PR Summary: Fix Agent Tags Implementation - Move to Top-Level Settings

TL;DR

Fixed Agent Tags location to comply with AsyncAPI specification. Moved tags from options.agent.tags to options.tags as a top-level property in SettingsOptions.


Problem

Agent Tags were incorrectly implemented as a nested property under the agent object (options.agent.tags), but the AsyncAPI specification clearly defines tags as a top-level property alongside type, experimental, audio, and agent.

Incorrect Structure (Before):

{
  "type": "Settings",
  "agent": {
    "tags": ["production", "support"],  // ❌ Wrong location
    "language": "en"
  }
}

Correct Structure (After):

{
  "type": "Settings", 
  "tags": ["production", "support"],  // ✅ Correct location
  "agent": {
    "language": "en"
  }
}

Solution

  1. Moved tags field from Agent class to SettingsOptions class as top-level property
  2. Updated all tests to use correct API: options.tags instead of options.agent.tags
  3. Maintained backward compatibility in serialization/deserialization logic

Files Changed

  • deepgram/clients/agent/v1/websocket/options.py - Core implementation fix
  • tests/unit_test/test_unit_agent_tags.py - Updated all 12 unit tests
  • tests/daily_test/test_daily_agent_websocket.py - Updated integration tests

API Change

Before (Incorrect):

options = SettingsOptions()
options.agent.tags = ["production", "support"]  # ❌ Wrong

After (Correct):

options = SettingsOptions()  
options.tags = ["production", "support"]  # ✅ Correct

Validation

  • Unit Tests: 12/12 Agent Tags tests pass
  • Integration Tests: 140/140 other unit tests pass (no regressions)
  • Daily Tests: 5/5 live integration tests pass (2:07 minutes)
  • Structure Validation: Confirmed serialized output matches AsyncAPI spec exactly

Non- Breaking Change Notice

This is not a breaking change for existing users of Agent Tags.

Since this was incorrectly introduced in PR #559 and doesn't work as implemented.

Impact

  • Spec Compliance: Now fully compliant with AsyncAPI specification
  • Server Compatibility: Proper tags transmission to Deepgram Agent services
  • Developer Experience: Consistent with documented API structure
  • Testing: Comprehensive validation across unit, integration, and live service tests

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
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • New Features

    • Added an example script demonstrating agent websocket client usage with tag support and event handling.
  • Bug Fixes

    • Updated handling of agent tags so they are now managed directly within settings, simplifying access and configuration.
  • Tests

    • Updated and refactored tests to reflect the new tag handling approach in settings.
    • Refreshed test data with updated timestamps, IDs, latency metrics, and minor text improvements for clarity.

@jpvajda jpvajda requested a review from naomi-lgbt August 1, 2025 23:04
Copy link
Contributor

coderabbitai bot commented Aug 1, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The tags field was moved from the Agent dataclass to the SettingsOptions dataclass in the agent websocket options module. All code, tests, and example scripts were updated to access and assign tags directly on SettingsOptions. Related test data and test logic were refactored to reflect this structural change.

Changes

Cohort / File(s) Change Summary
Agent Websocket Options Refactor
deepgram/clients/agent/v1/websocket/options.py
Removed tags from Agent dataclass; added tags to SettingsOptions dataclass.
Example Script Addition/Update
examples/agent/tags/main.py
Added example script demonstrating agent websocket client usage with tag support, event handling, and graceful shutdown.
Daily Agent Websocket Test Update
tests/daily_test/test_daily_agent_websocket.py
Updated test logic to assign and validate tags directly on settings instead of nested under agent_config.
Unit Test Refactor
tests/unit_test/test_unit_agent_tags.py
Refactored tests to access/assign tags directly on SettingsOptions; removed Agent import; updated serialization/deserialization checks accordingly.
Agent Websocket Response Data Updates
tests/response_data/agent/websocket/*-events.json
tests/response_data/agent/websocket/function_call_conversation-ac8ed698-function_calls.json
Updated test JSON data: new timestamps, request IDs, latency values, and minor text/content changes to align with new field structure and test coverage. No structural changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ExampleScript
    participant SettingsOptions
    participant AgentWebsocketClient

    User->>ExampleScript: Run script
    ExampleScript->>SettingsOptions: Create instance with tags
    ExampleScript->>AgentWebsocketClient: Initialize with SettingsOptions (tags included)
    AgentWebsocketClient->>AgentWebsocketClient: Connect and handle events
    AgentWebsocketClient-->>ExampleScript: Emit events (open, data, welcome, etc.)
    ExampleScript-->>User: Print event data and tags
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15–20 minutes

Possibly related PRs

Suggested reviewers

  • jpvajda

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
examples/agent/tags/main.py
tests/daily_test/test_daily_agent_websocket.py
  • 1 others

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 eca802a and 598fd9d.

📒 Files selected for processing (10)
  • deepgram/clients/agent/v1/websocket/options.py (2 hunks)
  • examples/agent/tags/main.py (1 hunks)
  • tests/daily_test/test_daily_agent_websocket.py (2 hunks)
  • tests/response_data/agent/websocket/agent_tags-e55ef69c-events.json (4 hunks)
  • tests/response_data/agent/websocket/basic_conversation-a40b2785-events.json (7 hunks)
  • tests/response_data/agent/websocket/fallback_providers-e16542b1-events.json (6 hunks)
  • tests/response_data/agent/websocket/function_call_conversation-ac8ed698-events.json (6 hunks)
  • tests/response_data/agent/websocket/function_call_conversation-ac8ed698-function_calls.json (3 hunks)
  • tests/response_data/agent/websocket/inject_agent_message-3c5004a4-events.json (5 hunks)
  • tests/unit_test/test_unit_agent_tags.py (4 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/agent-tags

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 added the bug Something isn't working label Aug 1, 2025
naomi-lgbt
naomi-lgbt previously approved these changes Aug 2, 2025
@naomi-lgbt naomi-lgbt merged commit 4fc8756 into main Aug 2, 2025
4 of 5 checks passed
@naomi-lgbt naomi-lgbt deleted the fix/agent-tags branch August 2, 2025 00:59
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.

2 participants