When using file search (FileSearchStore) with gemini-3-flash-preview, the API returns empty content instead of searching the file store and generating a response. The same request works correctly with gemini-2.5-flash.
Important Context
Interestingly, last week the behavior was reversed - gemini-2.5-flash would not work with file search, but gemini-3-flash-preview worked fine. Something appears to have changed on the backend that flipped which model family supports file search.
Environment
- SDK: google-genai 1.61.0
- Python: 3.13
- Date: February 2, 2026
Reproduction
“”"
Reproduction: Gemini 3 file search returns empty content
Usage:
export GEMINI_API_KEY=“your-key”
pip install google-genai
python gemini_file_search_bug.py
“”"
import os
import time
from google import genai
from google.genai import types
api_key = os.environ.get(“GEMINI_API_KEY”)
if not api_key:
print(“ERROR: Set GEMINI_API_KEY environment variable”)
exit(1)
client = genai.Client(api_key=api_key)
1. Create a file search store
print(“Creating file search store…”)
store = client.file_search_stores.create(
config={“display_name”: “test-store-bug-repro”}
)
print(f"Store created: {store.name}")
2. Create and upload a simple test file
test_content = “”"
Project Management Tools
get_stories
Fetches a list of task/story objects from the project.
post_stories
Creates a new task/story in the project.
get_users
Fetches a list of users in the account.
“”"
with open(“/tmp/test_tools.md”, “w”) as f:
f.write(test_content)
print(“Uploading file…”)
operation = client.file_search_stores.upload_to_file_search_store(
file=“/tmp/test_tools.md”,
file_search_store_name=store.name,
config={“display_name”: “test_tools.md”}
)
while not operation.done:
time.sleep(2)
operation = client.operations.get(operation)
print(“File uploaded and indexed”)
3. Test with Gemini 2.5 (WORKS)
print(“\n” + “=” * 50)
print(“Testing gemini-2.5-flash (EXPECTED: WORKS)”)
print(“=” * 50)
response_25 = client.models.generate_content(
model=“gemini-2.5-flash”,
contents=“What tools are available for creating tasks?”,
config=types.GenerateContentConfig(
tools=[
types.Tool(
file_search=types.FileSearch(
file_search_store_names=[store.name]
)
)
]
)
)
print(f"Has text: {bool(response_25.text)}“)
if response_25.text:
print(f"Response preview: {response_25.text[:200]}…”)
print(f"Finish reason: {response_25.candidates[0].finish_reason}")
4. Test with Gemini 3 (FAILS)
print(“\n” + “=” * 50)
print(“Testing gemini-3-flash-preview (EXPECTED: FAILS)”)
print(“=” * 50)
response_3 = client.models.generate_content(
model=“gemini-3-flash-preview”,
contents=“What tools are available for creating tasks?”,
config=types.GenerateContentConfig(
tools=[
types.Tool(
file_search=types.FileSearch(
file_search_store_names=[store.name]
)
)
]
)
)
print(f"Has text: {bool(response_3.text) if hasattr(response_3, ‘text’) and response_3.text else False}“)
print(f"Finish reason: {response_3.candidates[0].finish_reason}”)
content = response_3.candidates[0].content
print(f"Content parts: {content.parts if content and hasattr(content, ‘parts’) else ‘EMPTY/NONE’}")
Cleanup
print(“\n” + “=” * 50)
print(“Cleaning up…”)
try:
client.file_search_stores.delete(name=store.name, config={“force”: True})
print(“Done - store deleted”)
except Exception as e:
print(f"Cleanup failed (manual deletion required): {e}")
Output
Creating file search store…
Store created: fileSearchStores/teststorebugrepro-elwzsddjxpda
Uploading file…
File uploaded and indexed
==================================================
Testing gemini-2.5-flash (EXPECTED: WORKS)
Has text: True
Response preview: The post_stories tool is available for creating new tasks or stories…
Finish reason: FinishReason.STOP
==================================================
Testing gemini-3-flash-preview (EXPECTED: FAILS)
Has text: False
Finish reason: FinishReason.STOP
Finish message: None
Content parts: None
Expected Behavior
Both models should search the file store and return a text response about the available tools.
Actual Behavior
- gemini-2.5-flash:
Works correctly - gemini-3-flash-preview:
Returns empty content
Related
This may be related to: File Search Tool in combination with response schema not working