@@ -295,7 +295,6 @@ def test_retrieve_response_vector_db_available(mocker):
295295 documents = [],
296296 stream = False ,
297297 toolgroups = get_rag_toolgroups (["VectorDB-1" ]),
298- extra_headers = {"X-LlamaStack-Provider-Data" : '{"mcp_headers": {}}' },
299298 )
300299
301300
@@ -331,7 +330,6 @@ def test_retrieve_response_no_available_shields(mocker):
331330 documents = [],
332331 stream = False ,
333332 toolgroups = None ,
334- extra_headers = {"X-LlamaStack-Provider-Data" : '{"mcp_headers": {}}' },
335333 )
336334
337335
@@ -372,7 +370,6 @@ def __init__(self, identifier):
372370 documents = [],
373371 stream = False ,
374372 toolgroups = None ,
375- extra_headers = {"X-LlamaStack-Provider-Data" : '{"mcp_headers": {}}' },
376373 )
377374
378375
@@ -416,7 +413,6 @@ def __init__(self, identifier):
416413 documents = [],
417414 stream = False ,
418415 toolgroups = None ,
419- extra_headers = {"X-LlamaStack-Provider-Data" : '{"mcp_headers": {}}' },
420416 )
421417
422418
@@ -465,7 +461,6 @@ def test_retrieve_response_with_one_attachment(mocker):
465461 },
466462 ],
467463 toolgroups = None ,
468- extra_headers = {"X-LlamaStack-Provider-Data" : '{"mcp_headers": {}}' },
469464 )
470465
471466
@@ -523,7 +518,6 @@ def test_retrieve_response_with_two_attachments(mocker):
523518 },
524519 ],
525520 toolgroups = None ,
526- extra_headers = {"X-LlamaStack-Provider-Data" : '{"mcp_headers": {}}' },
527521 )
528522
529523
@@ -573,23 +567,28 @@ def test_retrieve_response_with_mcp_servers(mocker):
573567 None , # conversation_id
574568 )
575569
576- # Check that the agent's create_turn was called with MCP headers
577- mock_agent .create_turn .assert_called_once ()
578- call_args = mock_agent .create_turn .call_args
579-
580- extra_headers_data = json .loads (
581- call_args [1 ]["extra_headers" ]["X-LlamaStack-Provider-Data" ]
582- )
583- mcp_headers = extra_headers_data ["mcp_headers" ]
570+ # Check that the agent's extra_headers property was set correctly
571+ expected_extra_headers = {
572+ "X-LlamaStack-Provider-Data" : json .dumps (
573+ {
574+ "mcp_headers" : {
575+ "http://localhost:3000" : {"Authorization" : "Bearer test_token_123" },
576+ "https://git.example.com/mcp" : {
577+ "Authorization" : "Bearer test_token_123"
578+ },
579+ }
580+ }
581+ )
582+ }
583+ assert mock_agent .extra_headers == expected_extra_headers
584584
585- assert "http://localhost:3000" in mcp_headers
586- assert (
587- mcp_headers ["http://localhost:3000" ]["Authorization" ] == "Bearer test_token_123"
588- )
589- assert "https://git.example.com/mcp" in mcp_headers
590- assert (
591- mcp_headers ["https://git.example.com/mcp" ]["Authorization" ]
592- == "Bearer test_token_123"
585+ # Check that create_turn was called with the correct parameters
586+ mock_agent .create_turn .assert_called_once_with (
587+ messages = [UserMessage (role = "user" , content = "What is OpenStack?" )],
588+ session_id = "fake_session_id" ,
589+ documents = [],
590+ stream = False ,
591+ toolgroups = None ,
593592 )
594593
595594
@@ -632,15 +631,20 @@ def test_retrieve_response_with_mcp_servers_empty_token(mocker):
632631 None , # conversation_id
633632 )
634633
635- # Check that the agent's create_turn was called with empty MCP headers
636- mock_agent .create_turn .assert_called_once ()
637- call_args = mock_agent .create_turn .call_args
634+ # Check that the agent's extra_headers property was set correctly (empty mcp_headers)
635+ expected_extra_headers = {
636+ "X-LlamaStack-Provider-Data" : json .dumps ({"mcp_headers" : {}})
637+ }
638+ assert mock_agent .extra_headers == expected_extra_headers
638639
639- extra_headers_data = json .loads (
640- call_args [1 ]["extra_headers" ]["X-LlamaStack-Provider-Data" ]
640+ # Check that create_turn was called with the correct parameters
641+ mock_agent .create_turn .assert_called_once_with (
642+ messages = [UserMessage (role = "user" , content = "What is OpenStack?" )],
643+ session_id = "fake_session_id" ,
644+ documents = [],
645+ stream = False ,
646+ toolgroups = None ,
641647 )
642- mcp_headers = extra_headers_data ["mcp_headers" ]
643- assert len (mcp_headers ) == 0
644648
645649
646650def test_construct_transcripts_path (setup_configuration , mocker ):
0 commit comments