Skip to content

Deploy to Cloud Run using adk deploy cloud_run is not working #3052

@v360-eduardo-marques

Description

@v360-eduardo-marques

I built a simple agent and I'm trying to deploy to Cloud Run using VertexAiSessionService. When I run adk deploy cloud_run its seems to work. But when I try to create a session using CURL I get a 500 - Internal Server Error

To Reproduce

Steps to reproduce the behavior:

  1. Install adk pip install google-adk==1.15.1
  2. Create simple agent
from google.adk.agents import Agent

system_instruction = (
    "Just say hi and be nice"
)

root_agent = Agent(
    name="my_test_agent",
    model='gemini-2.5-flash',
    instruction=system_instruction,
    description="Test agent",
)
  1. Deploy the agent
adk deploy cloud_run \
    --project=<project_id> \
    --region=us-central1 \
    --service_name=my-agent \
    --app_name=my_agent \
    --session_service_uri='agentengine://<reasoning_engines_id ex:12342341234>' \
    --with_ui \
    my_agent
  1. Try to create a session using curl
curl -X POST \
     $AGENT_URL/apps/my_agent/users/user_123/sessions/session_abc \
    -H "Content-Type: application/json" \
    -d '{"state": {"preferred_language": "English", "visit_count": 5}}'
  1. Stacktrace of the error (Cloud Log
Traceback (most recent call last):
  File "/home/myuser/.local/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/fastapi/applications.py", line 1133, in __call__
    await super().__call__(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/applications.py", line 113, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 63, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/myuser/.local/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 18, in __call__
    await self.app(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/routing.py", line 716, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/routing.py", line 736, in app
    await route.handle(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/routing.py", line 290, in handle
    await self.app(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/fastapi/routing.py", line 123, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/home/myuser/.local/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/home/myuser/.local/lib/python3.11/site-packages/fastapi/routing.py", line 109, in app
    response = await f(request)
               ^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/fastapi/routing.py", line 387, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/fastapi/routing.py", line 288, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/google/adk/cli/adk_web_server.py", line 1252, in run_agent_sse
    session = await self.session_service.get_session(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 195, in get_session
    get_session_api_response = await self._get_session_api_response(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 77, in _get_session_api_response
    get_session_api_response = await api_client.async_request(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/google/genai/_api_client.py", line 1325, in async_request
    result = await self._async_request(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/google/genai/_api_client.py", line 1270, in _async_request
    return await self._async_retry(  # type: ignore[no-any-return]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 111, in __call__
    do = await self.iter(retry_state=retry_state)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
    result = await action(retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/tenacity/_utils.py", line 99, in inner
    return call(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/tenacity/__init__.py", line 418, in exc_check
    raise retry_exc.reraise()
          ^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/tenacity/__init__.py", line 185, in reraise
    raise self.last_attempt.result()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 449, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/home/myuser/.local/lib/python3.11/site-packages/tenacity/asyncio/__init__.py", line 114, in __call__
    result = await fn(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/myuser/.local/lib/python3.11/site-packages/google/genai/_api_client.py", line 1250, in _async_request_once
    await errors.APIError.raise_for_async_response(client_response)
  File "/home/myuser/.local/lib/python3.11/site-packages/google/genai/errors.py", line 159, in raise_for_async_response
    raise ClientError(status_code, response_json, response)
google.genai.errors.ClientError: 404 NOT_FOUND. {'error': {'code': 404, 'message': 'Session (projectNumber: <project_number>, reasoningEngineId: <engine_id>, sessionId: 8859714613281816577) not found.', 'status': 'NOT_FOUND'}}

Desktop (please complete the following information):

  • OS: macOS
  • Python version(python -V): 3.11.9
  • ADK version(pip show google-adk): 1.15.1

Screenshots
project structure
Image

Metadata

Metadata

Assignees

Labels

good first issue[Community] This issue is good for newcomers to participateservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions