{"record":{"id":"c7ed8304d8c7e868","repo":"microsoft/autogen","slug":"file-search-is-not-enabled-for-this-assistant-add","errorCode":null,"errorMessage":"File search is not enabled for this assistant. Add a file_search tool when creating the assistant.","messagePattern":"File search is not enabled for this assistant\\. Add a file_search tool when creating the assistant\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py","lineNumber":1029,"sourceCode":"\n        Args:\n            file_paths (str | Iterable[str]): Path(s) to file(s) to upload\n            cancellation_token (CancellationToken): Token for cancellation handling\n            vector_store_name (Optional[str]): Name to assign to the vector store if creating a new one\n            data_sources (Optional[List[VectorStoreDataSource]]): Additional data sources for the vector store\n            expires_after (Optional[VectorStoreExpirationPolicy]): Expiration policy for vector store content\n            chunking_strategy (Optional[VectorStoreChunkingStrategyRequest]): Strategy for chunking file content\n            vector_store_metadata (Optional[Dict[str, str]]): Additional metadata for the vector store\n            vector_store_polling_interval (float): Time to sleep between polling for vector store status\n\n        Raises:\n            ValueError: If file search is not enabled for this agent or file upload fails\n        \"\"\"\n        await self._ensure_initialized()\n\n        # Check if file_search is enabled in tools\n        if not any(isinstance(tool, FileSearchToolDefinition) for tool in self._api_tools):\n            raise ValueError(\n                \"File search is not enabled for this assistant. Add a file_search tool when creating the assistant.\"\n            )\n\n        # Create vector store if not already created\n        if self._vector_store_id is None:\n            vector_store: VectorStore = await cancellation_token.link_future(\n                asyncio.ensure_future(\n                    self._project_client.agents.vector_stores.create_and_poll(\n                        file_ids=[],\n                        name=vector_store_name,\n                        data_sources=data_sources,\n                        expires_after=expires_after,\n                        chunking_strategy=chunking_strategy,\n                        metadata=vector_store_metadata,\n                        polling_interval=vector_store_polling_interval,\n                    )\n                )\n            )","sourceCodeStart":1011,"sourceCodeEnd":1047,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py#L1011-L1047","documentation":"Raised by the file-search ingestion path (adding files/vector stores to the assistant) when the agent's registered API tools contain no FileSearchToolDefinition. File search requires the assistant to have been created with the file_search tool; you cannot add vector stores to an assistant that lacks it.","triggerScenarios":"Calling the agent's file-search setup method (e.g. adding files for search) on an AzureAIAgent constructed with tools=[\"code_interpreter\"], no tools, or only function tools.","commonSituations":"Enabling file search later after creating the agent without it; passing tools=[] intending to configure everything later; typos in the tool string so file_search never registered.","solutions":["Recreate (or reconfigure) the agent with tools including \"file_search\" or a FileSearchToolDefinition before calling the file-search API.","Verify via agent.tools / the service that file_search is present on the assistant before ingestion calls.","Structure startup code so all built-in tools are declared at construction time."],"exampleFix":"# before\nagent = AzureAIAgent(client, name=\"a\", tools=[\"code_interpreter\"])\nawait agent.<file_search_ingest>(...)\n# after\nagent = AzureAIAgent(client, name=\"a\", tools=[\"code_interpreter\", \"file_search\"])\nawait agent.<file_search_ingest>(...)","handlingStrategy":"validation","validationCode":"from azure.ai.projects.models import FileSearchToolDefinition\nenabled = any(isinstance(t, FileSearchToolDefinition) for t in agent.tools)\nif not enabled:\n    raise ValueError(\"Recreate agent with the file_search tool before ingestion\")","typeGuard":null,"tryCatchPattern":"try:\n    await ingest_files(agent, paths)\nexcept ValueError as e:\n    if \"File search is not enabled\" in str(e):\n        agent = AzureAIAgent(client, tools=[*old_tools, \"file_search\"])\n        await ingest_files(agent, paths)","preventionTips":["Declare all built-in tools (file_search, etc.) at agent construction.","Assert agent.tools contains FileSearchToolDefinition before any file-search ingestion.","Don't create agents with tools=[] intending to add built-ins later."],"tags":["azure","file-search","tools","azure-ai-agent"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}