googleapis / googleapis/python-genai
AsyncModels.generate_content crashes with cannot pickle '_asyncio.Future' when config is a GenerateContentConfig object containing an MCP ClientSession tool
- Dominant language
- Python
- Stars
- 4k
- Forks
- 1k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 40
Description
### Environment
- google-genai: 2.9.0
- mcp: 1.28.1
- Python: 3.12.13
### The issue
Passing a live MCP ClientSession as a tool works when config is a dict, but the same settings passed as a GenerateContentConfig object raise TypeError: cannot pickle '_asyncio.Future' object.
In AsyncModels.generate_content, the config is deep-copied before MCP sessions are extracted — google/genai/models.py (2.9.0)
### Steps to reproduce
1. Create a live MCP ClientSession and pass it as a tool to aio.models.generate_content, with config as a GenerateContentConfig object:
config=types.GenerateContentConfig(tools=[session]).
2. The call raises TypeError: cannot pickle '_asyncio.Future' object before any network request.
3. Pass the same settings as a dict instead — config={"tools": [session]} — and it works (session is extracted, request proceeds normally).
Contributor guide
Assessment
This issue has not been assessed yet.