@@ -557,6 +557,12 @@ def test_save_manual_chunking(self, mocker, llama_stack_processor):
557557 assert call_kwargs ["vector_store_id" ] == "vs_123"
558558 assert "chunks" in call_kwargs
559559 assert len (call_kwargs ["chunks" ]) == 2
560+ # Verify index name is embedded in chunk metadata as "source"
561+ # and existing metadata keys are preserved
562+ for chunk in call_kwargs ["chunks" ]:
563+ assert chunk ["metadata" ]["source" ] == mock .sentinel .index
564+ assert "title" in chunk ["metadata" ]
565+ assert "docs_url" in chunk ["metadata" ]
560566
561567 def test_save_auto_chunking (self , mocker , llama_stack_processor ):
562568 """Test saving documents with automatic chunking workflow."""
@@ -566,3 +572,9 @@ def test_save_auto_chunking(self, mocker, llama_stack_processor):
566572 # Verify files.create was called for each document (single file upload)
567573 assert client .files .create .await_count == 2
568574 assert client .vector_stores .files .create .await_count == 2
575+ # Verify index name is embedded in file attributes as "source"
576+ # and existing metadata keys are preserved
577+ for call in client .vector_stores .files .create .await_args_list :
578+ assert call .kwargs ["attributes" ]["source" ] == mock .sentinel .index
579+ assert "title" in call .kwargs ["attributes" ]
580+ assert "document_id" in call .kwargs ["attributes" ]
0 commit comments