microsoft/autogen · error · ValueError

File search is not enabled for this assistant. Add a file_se

Error message

File search is not enabled for this assistant. Add a file_search tool when creating the assistant.

What it means

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.

Source

Thrown at python/packages/autogen-ext/src/autogen_ext/agents/azure/_azure_ai_agent.py:1029

        Args:
            file_paths (str | Iterable[str]): Path(s) to file(s) to upload
            cancellation_token (CancellationToken): Token for cancellation handling
            vector_store_name (Optional[str]): Name to assign to the vector store if creating a new one
            data_sources (Optional[List[VectorStoreDataSource]]): Additional data sources for the vector store
            expires_after (Optional[VectorStoreExpirationPolicy]): Expiration policy for vector store content
            chunking_strategy (Optional[VectorStoreChunkingStrategyRequest]): Strategy for chunking file content
            vector_store_metadata (Optional[Dict[str, str]]): Additional metadata for the vector store
            vector_store_polling_interval (float): Time to sleep between polling for vector store status

        Raises:
            ValueError: If file search is not enabled for this agent or file upload fails
        """
        await self._ensure_initialized()

        # Check if file_search is enabled in tools
        if not any(isinstance(tool, FileSearchToolDefinition) for tool in self._api_tools):
            raise ValueError(
                "File search is not enabled for this assistant. Add a file_search tool when creating the assistant."
            )

        # Create vector store if not already created
        if self._vector_store_id is None:
            vector_store: VectorStore = await cancellation_token.link_future(
                asyncio.ensure_future(
                    self._project_client.agents.vector_stores.create_and_poll(
                        file_ids=[],
                        name=vector_store_name,
                        data_sources=data_sources,
                        expires_after=expires_after,
                        chunking_strategy=chunking_strategy,
                        metadata=vector_store_metadata,
                        polling_interval=vector_store_polling_interval,
                    )
                )
            )

View on GitHub (pinned to 027ecf0a37)

Solutions

  1. Recreate (or reconfigure) the agent with tools including "file_search" or a FileSearchToolDefinition before calling the file-search API.
  2. Verify via agent.tools / the service that file_search is present on the assistant before ingestion calls.
  3. Structure startup code so all built-in tools are declared at construction time.

Example fix

# before
agent = AzureAIAgent(client, name="a", tools=["code_interpreter"])
await agent.<file_search_ingest>(...)
# after
agent = AzureAIAgent(client, name="a", tools=["code_interpreter", "file_search"])
await agent.<file_search_ingest>(...)
Defensive patterns

Strategy: validation

Validate before calling

from azure.ai.projects.models import FileSearchToolDefinition
enabled = any(isinstance(t, FileSearchToolDefinition) for t in agent.tools)
if not enabled:
    raise ValueError("Recreate agent with the file_search tool before ingestion")

Try / catch

try:
    await ingest_files(agent, paths)
except ValueError as e:
    if "File search is not enabled" in str(e):
        agent = AzureAIAgent(client, tools=[*old_tools, "file_search"])
        await ingest_files(agent, paths)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15). Data as JSON: /api/errors/c7ed8304d8c7e868. Report an issue: GitHub.