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
on_upload_for_file_search uploads files into an OpenAI vector store and attaches it to the assistant. It requires that a file_search tool be part of the assistant's tool configuration (checked against self._api_tools); without file_search enabled the upload has nothing to attach to, so it refuses with this ValueError.
Source
Thrown at python/packages/autogen-ext/src/autogen_ext/agents/openai/_openai_assistant_agent.py:633
await cancellation_token.link_future(
asyncio.ensure_future(
self._client.beta.threads.update( # type: ignore[reportDeprecated]
thread_id=self._thread_id,
tool_resources=cast(thread_update_params.ToolResources, tool_resources.model_dump()),
)
)
)
async def on_upload_for_file_search(
self, file_paths: str | Iterable[str], cancellation_token: CancellationToken
) -> None:
"""Handle file uploads for file search."""
await self._ensure_initialized()
# Check if file_search is enabled in tools
if not any(tool.get("type") == "file_search" 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._client.vector_stores.create())
)
self._vector_store_id = vector_store.id
# Update assistant with vector store ID
await cancellation_token.link_future(
asyncio.ensure_future(
self._client.beta.assistants.update(
assistant_id=self._get_assistant_id,
tool_resources={"file_search": {"vector_store_ids": [self._vector_store_id]}},
)
)View on GitHub (pinned to 027ecf0a37)
Solutions
- Include file_search when creating the agent: tools=["file_search", ...] (string form works for the assistant agent).
- If using tool_resources/file search resources, ensure the file_search tool itself is registered too.
- Recreate the assistant with the updated tool set rather than uploading to a non-file-search assistant.
Example fix
# before
agent = OpenAIAssistantAgent(
name="docs", instructions="...", model="gpt-4o", client=cl, tools=[]
)
await agent.on_upload_for_file_search("report.pdf", ct) # raises
# after
agent = OpenAIAssistantAgent(
name="docs", instructions="...", model="gpt-4o", client=cl,
tools=["file_search"],
)
await agent.on_upload_for_file_search("report.pdf", ct) Defensive patterns
Strategy: validation
Validate before calling
file_search_enabled = any(
(t.get("type") if isinstance(t, dict) else t) == "file_search" for t in tools
)
if not file_search_enabled:
raise ConfigError("add 'file_search' to tools before uploading files") Prevention
- Declare file_search in the agent's tools at creation time.
- Gate upload UIs/features on the agent's tool configuration.
- Remember tool capability is fixed at assistant creation, not at upload.
When it happens
Trigger: Creating OpenAIAssistantAgent(..., tools=[...]) without a file_search tool entry (or without tool_resources containing file_search), then calling await agent.on_upload_for_file_search(paths, ct).
Common situations: Adding file upload to an existing agent that was configured for function tools only; forgetting that file_search must be declared at assistant creation, not at upload time.
Related errors
- No tools are available.
- Please set OPENAI_API_KEY environment variable.
- Please set OPENAI_API_KEY environment variable.
- Please set OPENAI_API_KEY environment variable.
- Please set OPENAI_API_KEY environment variable.
AI-assisted analysis of microsoft/autogen@027ecf0a37 (2026-08-15).
Data as JSON: /api/errors/e2c09f1c59a8e84d.
Report an issue: GitHub.