async def test_rag_prompt_with_task_prompt(self, mock_providers, mock_search_results):
        """Test RAG prompt construction with a task prompt."""
        class RAGPromptBuilder:
            def __init__(self, providers):
                self.providers = providers

            async def build_prompt(self, query, search_results, system_prompt_template_id=None, task_prompt=None):
                # Simple implementation that handles search results
                chunks = search_results.get("chunk_search_results", [])

                context = ""
                for i, chunk in enumerate(chunks):
                    # Format the chunk text
                    chunk_text = f"[{i+1}] {chunk.get('text', '')}"

                    context += chunk_text + "\n\n"

                if task_prompt:
                    context += f"\n\nTask: {task_prompt}"

                return [
                    {"role": "system", "content": f"System prompt with context:\n\n{context}"},
                    {"role": "user", "content": query}
                ]

        # Create a RAG prompt builder
        builder = RAGPromptBuilder(providers=mock_providers)

        # Call the build method with a task prompt
        query = "What did Aristotle say about ethics?"
        task_prompt = "Summarize the information and provide key points only"
        messages = await builder.build_prompt(
            query=query,
            search_results=mock_search_results,
            system_prompt_template_id="default_rag_prompt",
            task_prompt=task_prompt
        )

        # Find the messages
        system_message = next((m for m in messages if m["role"] == "system"), None)
        user_message = next((m for m in messages if m["role"] == "user"), None)

        # Check that task prompt was incorporated
        assert task_prompt in system_message["content"] or task_prompt in user_message["content"], \
            "Task prompt should be incorporated into the messages"
Test RAG prompt construction with a task prompt.
py/tests/unit/retrieval/test_rag_processing.py