googleapis / googleapis/python-aiplatform
In the "agent_engine" module, the function "async_stream_query" on a remote app, blocks the thread
- Ngôn ngữ chính
- Python
- Star
- 905
- Fork
- 465
- Merge trung bình
- 1 ngày 13 giờ
- Pull request đã merge (30 ngày)
- 44
Mô tả
There seems to be an issue with the "async_stream_query" function, when trying to invoke it on a remote app deployed in Vertex AI Agents Engine
This should be an asynchronous generator, but it blocks the entire thread until all the results are returned from the app
When using the same function on a local running agent, it does work as expected
#### Environment details
- OS type and version: macOS 15.6.1
- Python version: 3.12.8
- uv version: 0.5.7
- `google-cloud-aiplatform` version: 1.126.1
#### Steps to reproduce
1. Deploy to GCP Agents Engine an agent with tool that take long time to run
2. Run the following code:
```python
import asyncio
from vertexai import agent_engines
import vertexai
PROJECT_ID = "..."
LOCATION = "..."
STAGING_BUCKET = "..."
vertexai.init(
project=PROJECT_ID,
location=LOCATION,
staging_bucket=STAGING_BUCKET,
)
async def run_local_loop():
while True:
await asyncio.sleep(1)
print("ping")
async def run_remote_app():
await asyncio.sleep(3)
remote_app = agent_engines.get(
resource_name="...",
)
async for event in remote_app.async_stream_query(
user_id="test_user",
message="test message",
):
print(event)
async def main():
await asyncio.gather(run_local_loop(), run_remote_app())
asyncio.run(main())
```
The above code will start printing "ping" every second, but once it reaches the "async_stream_query", it will stop, blocking the thread
But if instead of using the "agent_engines.get" to get a remote app, you create a local app:
```
agent_engines.AdkApp(
agent=root_agent,
enable_tracing=True,
)
```
The code does work as expected and it will keep printing "ping" every second, while waiting for events from the app
Please take a look and let me know if it is indeed an issue or am I missing something here
Thanks!
Hướng dẫn đóng góp
Hướng nghiên cứu
Điểm vào được báo cáo là remote_app.async_stream_query, được lấy thông qua agent_engines.get; trước tiên hãy tái hiện ví dụ asyncio.gather và so sánh với AdkApp cục bộ. Công việc được xem là hoàn tất khi remote stream không còn chặn run_local_loop và các event vẫn được yield một cách bất đồng bộ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- google-cloud, python
- Lĩnh vực
- ai, cloud
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100