8383 },
8484 {
8585 "name" : "inject_agent_message" ,
86- "description" : "Test inject_agent_message functionality (expected to fail until #553 is resolved) " ,
86+ "description" : "Test inject_agent_message functionality" ,
8787 "agent_config" : {
8888 "think" : {
8989 "provider" : {"type" : "open_ai" , "model" : "gpt-4o-mini" },
112112 "test_inject_user_message" : True ,
113113 "test_inject_agent_message" : True ,
114114 "test_function_calls" : False ,
115- "expect_error" : True # Still expecting errors due to SDK function calling bugs (#528)
115+ "expect_error" : False # Function calling should now work properly
116116 },
117117 {
118118 "name" : "function_call_conversation" ,
119- "description" : "Test function calling with corrected HTTP method case (expected to fail due to #528) " ,
119+ "description" : "Test function calling functionality " ,
120120 "agent_config" : {
121121 "think" : {
122122 "provider" : {"type" : "open_ai" , "model" : "gpt-4o-mini" },
135135 },
136136 "required" : ["location" ]
137137 },
138- "method" : "get" ,
139- "url" : "https://api.example.com/weather"
138+ # For server side function testing only. Leave commented out to test client side unless you have a real URL to use here.
139+ # "endpoint": {
140+ # "url": "https://api.example.com/weather",
141+ # "method": "GET"
142+ # }
140143 }
141144 ]
142145 },
161164 "test_inject_user_message" : True ,
162165 "test_inject_agent_message" : False ,
163166 "test_function_calls" : True ,
164- "expect_error" : True # Still expecting errors due to SDK function calling bugs
167+ "expect_error" : False
168+ },
169+ {
170+ "name" : "agent_tags" ,
171+ "description" : "Test agent tags functionality with metadata labeling" ,
172+ "agent_config" : {
173+ "think" : {
174+ "provider" : {"type" : "open_ai" , "model" : "gpt-4o-mini" },
175+ "prompt" : "You are a helpful AI assistant for testing tag functionality."
176+ },
177+ "speak" : {"provider" : {"type" : "deepgram" , "model" : "aura-2-thalia-en" }},
178+ "listen" : {"provider" : {"type" : "deepgram" , "model" : "nova-3" }},
179+ "language" : "en"
180+ },
181+ "inject_messages" : [
182+ "Hello, this is a test of agent tags functionality." ,
183+ "Can you confirm you are working with tags enabled?"
184+ ],
185+ "expected_events" : [
186+ "Welcome" ,
187+ "SettingsApplied" ,
188+ "ConversationText" ,
189+ "AgentAudioDone"
190+ ],
191+ "test_inject_user_message" : True , # Test injection without tags for now
192+ "test_inject_agent_message" : False ,
193+ "test_function_calls" : False ,
194+ "test_agent_tags" : False # Disable tags test until server-side is ready
165195 },
166- # NOTE: function_call_conversation and inject_agent_message tests are marked as xfail
167- # - function_call_conversation: #528 - SDK function calling structure doesn't match new API spec
168- # - inject_agent_message: #553 - SDK missing inject_agent_message method implementation
169- # TODO: These should be re-enabled once the bugs are fixed
170196]
171197
172-
173198@pytest .mark .parametrize ("test_case" , test_cases )
174199def test_daily_agent_websocket (test_case : Dict [str , Any ]):
175200 """
@@ -189,12 +214,6 @@ def test_daily_agent_websocket(test_case: Dict[str, Any]):
189214 Note: some features might have bugs, like inject_agent_message and function_call_conversation. We intend to fix these in the future and update the tests.
190215 """
191216
192- # Mark tests as expected to fail for known issues
193- if test_case ["name" ] == "inject_agent_message" :
194- pytest .xfail (reason = "#553 - inject_agent_message method not implemented in SDK" )
195- elif test_case ["name" ] == "function_call_conversation" :
196- pytest .xfail (reason = "#528 - SDK function calling structure doesn't match new API spec" )
197-
198217 # Check for required environment variables
199218 if not os .getenv ("DEEPGRAM_API_KEY" ):
200219 pytest .skip ("DEEPGRAM_API_KEY environment variable not set" )
@@ -328,22 +347,24 @@ def on_function_call_request(self, function_call_request: FunctionCallRequest, *
328347 })
329348 print (f"🚨 SDK Bug detected: { bug_details } " )
330349
331- # Respond to function call using current SDK structure (even though it's wrong)
350+ # Respond to function call using new API structure
332351 try :
333- if hasattr (function_call_request , 'function_call_id' ):
334- # Use SDK's incorrect structure
352+ if function_call_request .functions and len (function_call_request .functions ) > 0 :
353+ # Use new API spec structure
354+ first_function = function_call_request .functions [0 ]
335355 response = FunctionCallResponse (
336- function_call_id = function_call_request .function_call_id ,
337- output = json .dumps ({
356+ id = first_function .id ,
357+ name = first_function .name ,
358+ content = json .dumps ({
338359 "success" : True ,
339360 "result" : "Mock function response" ,
340361 "timestamp" : time .time ()
341362 })
342363 )
343- dg_connection .send_function_call_response (response )
344- print (f"✓ Function call response sent using SDK structure" )
364+ dg_connection .send (response . to_json () )
365+ print (f"✓ Function call response sent using new API structure" )
345366 else :
346- print (f"❌ Cannot respond to function call - no function_call_id field " )
367+ print (f"❌ Cannot respond to function call - no functions in request " )
347368 except Exception as e :
348369 print (f"❌ Function call response failed: { e } " )
349370 received_events .append ({
@@ -409,7 +430,13 @@ def on_unhandled(self, unhandled, **kwargs):
409430 try :
410431 # Create enhanced settings from test case
411432 settings = SettingsOptions ()
412- settings .agent = test_case ["agent_config" ]
433+
434+ # Handle special agent tags test case by adding tags to the config
435+ agent_config = test_case ["agent_config" ].copy ()
436+ if test_case .get ("test_agent_tags" , False ):
437+ agent_config ["tags" ] = ["test" , "daily" ]
438+
439+ settings .agent = agent_config
413440 settings .experimental = True # Enable experimental features
414441
415442 print (f"🔧 Starting connection with settings: { settings .to_dict ()} " )
@@ -485,8 +512,9 @@ def on_unhandled(self, unhandled, **kwargs):
485512 if response_timeout >= 15 :
486513 print (f"⚠️ No events received after agent message { i + 1 } " )
487514
488- # Allow final processing
489- time .sleep (3 )
515+ # Allow final processing - wait longer for AgentAudioDone event
516+ print (f"⏳ Waiting 20 seconds for agent to complete speaking..." )
517+ time .sleep (20 )
490518 print ("\n --- Test Results Analysis ---" )
491519
492520 # Test 4: Validate expected events were received
@@ -512,7 +540,19 @@ def on_unhandled(self, unhandled, **kwargs):
512540 print (f"ℹ️ Conditional event not received (expected in error scenario): { conditional_event } " )
513541 else :
514542 # For non-error scenarios, require conditional events
543+ print (f"🔍 Debug: Expected conditional events: { conditional_events } " )
544+ print (f"🔍 Debug: All received events: { event_types } " )
545+ missing_events = [e for e in conditional_events if e not in event_types ]
546+ if missing_events :
547+ print (f"❌ Debug: Missing conditional events: { missing_events } " )
548+
515549 for conditional_event in conditional_events :
550+ if conditional_event not in event_types :
551+ print (f"💔 FAILURE DEBUG: Missing '{ conditional_event } ' event" )
552+ print (f"💔 Recent events (last 5): { event_types [- 5 :]} " )
553+ print (f"💔 Total events received: { len (event_types )} " )
554+ print (f"💔 AgentStartedSpeaking found: { 'AgentStartedSpeaking' in event_types } " )
555+ print (f"💔 AgentAudioDone found: { 'AgentAudioDone' in event_types } " )
516556 assert conditional_event in event_types , f"Test ID: { unique } - Should receive { conditional_event } event"
517557 print (f"✓ Conditional event received: { conditional_event } " )
518558
@@ -521,6 +561,24 @@ def on_unhandled(self, unhandled, **kwargs):
521561 assert len (conversation_text_list ) > 0 , f"Test ID: { unique } - Should receive conversation text"
522562 print (f"✓ Conversation flow validated ({ len (conversation_text_list )} conversation texts)" )
523563
564+ # Test 5a: Validate agent tags configuration
565+ if test_case .get ("test_agent_tags" , False ):
566+ print ("\n --- Agent Tags Validation ---" )
567+ # Verify tags were properly set in the agent configuration
568+ expected_tags = ["test" , "daily" ]
569+ # Verify settings contain the expected tags
570+ settings_dict = settings .to_dict ()
571+ agent_tags = settings_dict .get ("agent" , {}).get ("tags" , [])
572+ assert agent_tags == expected_tags , f"Test ID: { unique } - Agent tags should match expected tags"
573+ print (f"✓ Agent tags validated: { agent_tags } " )
574+
575+ # Verify tags are properly formatted (list of strings)
576+ assert isinstance (agent_tags , list ), f"Test ID: { unique } - Tags should be a list"
577+ assert all (isinstance (tag , str ) for tag in agent_tags ), f"Test ID: { unique } - All tags should be strings"
578+ print (f"✓ Agent tags format validated: { len (agent_tags )} tags, all strings" )
579+ else :
580+ print ("ℹ️ No tags specified for this test case" )
581+
524582 # Test 6: Validate function calls and detect SDK bugs
525583 if test_case .get ("test_function_calls" , False ):
526584 print ("\n --- Function Call Analysis ---" )
@@ -612,6 +670,11 @@ def on_unhandled(self, unhandled, **kwargs):
612670 print (f" SDK bugs detected: { len (function_call_bugs )} " )
613671 print (f" Injection refused: { len (injection_refused_events )} " )
614672
673+ # Report agent tags information if applicable
674+ if test_case .get ("test_agent_tags" , False ):
675+ expected_tags = test_case ["agent_config" ].get ("tags" , [])
676+ print (f" Agent tags tested: { expected_tags } " )
677+
615678 # Count and report unhandled events
616679 unhandled_events = [e for e in received_events if e ["type" ] == "Unhandled" ]
617680 if unhandled_events :
0 commit comments