googleapis / googleapis/python-aiplatform

In the "agent_engine" module, the function "async_stream_query" on a remote app, blocks the thread

Offen
#6,112 0 Kommentare 4 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
api: vertex-ai
Vorherrschende Sprache
Python
Sterne
905
Forks
465
Ø Merge
1 T. 13 Std.
Gemergte PRs (30 T.)
44

Beschreibung

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!

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.