googleapis / googleapis/python-aiplatform
ADK Agent Engine Agent fails to use MCP. Error point at bad handling of session management in async context
- 主要语言
- Python
- 星标
- 905
- 派生
- 465
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 44
描述
crossposting this as it seems it might be a vertexai issue rather https://github.com/google/adk-python/issues/3950 This only happens in agent engine, adk web works well
Running the example
```
# Your ADK agent connects to the remote MCP service via Streamable HTTP
McpToolset(
connection_params=StreamableHTTPConnectionParams(
url="https://your-mcp-server-url.run.app/mcp",
headers={"Authorization": "Bearer your-auth-token"}
),
)
```
My agent in agent engine is having issues answering questions, I'm using Gemini Enterprise as the interface.
After each call to the mcp the agent fails giving me the option to regenerate the response, it seems it tries to re use the previous session but fails with error messages such as:
`Error: an error occured during closing of asynchronous generator `
`RuntimeError: Attempted to exit cancel scope in a different task than it was entered in`
`RuntimeError: ahtrow(): asynchrnous generator is already running`
I'm deploying using all the latest versions from google-genai, google-adk and google-cloud-aiplatform
I can share more details, but I can't see anything special about my setup
Additional context
When running this locally via ADK web I see no issues at all.
I'm using PSC I to connect to the MCP running in a cloud run server. The connections are not stateless
贡献指南
调研方向
从 StreamableHTTPConnectionParams/McpToolset 示例开始,并在 Agent Engine 中复现它,同时与正常工作的 ADK web 路径进行比较。跟踪重复 MCP 调用周围的会话清理和复用;完成标准是 Agent Engine 能够在每次调用后进行响应,且不会出现 asynchronous-generator 或 cancel-scope 错误。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- google-cloud, python
- 领域
- backend-api-design, cloud
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100