Alejandro Capellán • 11 months ago
Error HttpResponse for each new AI Agent deployed to AI Engine #1525
I know this is not the place for technical problems, but I haven't receive any response in Github or GC community. And this has been driving me crazy for almost a week.
I was able to deploy a test agent to Vertex AI's Engine AI. I can create remote sessions and interact with it.
But when I tried to deploy my production agent it is just IMPOSSIBLE. I have been trying over and over and over with different variations. I even tried to deployed a very simple Agent with no tools and still wasn't possible.
It is always the same. I am able to deploy the agent to Reasoning Engine, i get a link like this:
projects/XXXXXXXXX/locations/us-central1/reasoningEngines/XXXXXXXXX
But whenever I try to create a session I run into this error:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/threading.py", line 1016, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.10/threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.10/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 826, in _asyncio_thread_main
result = asyncio.run(_invoke_async_create_session())
File "/usr/local/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/usr/local/lib/python3.10/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 817, in _invoke_async_create_session
return await self.async_create_session(
File "/usr/local/lib/python3.10/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 796, in async_create_session
session = await self._tmpl_attrs.get("session_service").create_session(
File "/usr/local/lib/python3.10/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 92, in create_session
session_id = api_response['name'].split('/')[-3]
TypeError: 'HttpResponse' object is not subscriptable
If anyone knows how to fix it please let me know!
Comments are closed.

5 comments
Private user • 11 months ago
The create_session method needs the api_response to be a dictionary but it is in fact getting HttpResponse Object not JSON . Here in the end of the error you've attached session_id = api_response['name'].split('/')[-3] assumes api_response to be a dict with 'name' field but it is getting HttpResponse Object ,However the error comes from the ADK package itself so maybe somewhere in your code you forgot to await when you create_session is async if that's the case then it would return coroutine thus the internal code breaks ,also make sure to use the same PROJECT_ID ,REGION , ENGINE_ID "matches the deployed agent" as the engine was deployed in cause if they were wrong then API wil reply with error message not a successful JSON so maybe the ADK then didn't check the response status code or content before trying to access response['name'] . its hard to tell exactly what gone wrong so it is better if you log the create_session response so you can see what the API is returning
Michelle Brain Manager • 11 months ago
Hello! Thanks for sharing this. We have the following response from the Google team split in a few parts. Best of luck!
Given that a test agent works but your production agent doesn't, this strongly suggests a difference in permissions, API enablement, or configuration between the two.
1. Service Account Permissions (Most Common Culprit):
Problem: The service account that the Vertex AI Reasoning Engine (your deployed agent) is running as does not have the necessary permissions to call the Vertex AI Agent Engine Session API. Even if it has permissions to run models or use other Vertex AI services, it needs specific permissions for sessions.
Solution:
Identify the Service Account your Reasoning Engine deployment is using. When you deploy a Reasoning Engine, you typically specify a service account. If not, it defaults to the Compute Engine default service account (e.g., [PROJECT_NUMBER]-compute@developer.gserviceaccount.com).
Go to IAM & Admin > Service Accounts in your Google Cloud Console.
Find this service account.
Ensure it has the following IAM roles:
Vertex AI User (provides broad access to Vertex AI resources, including models and endpoints).
Service Account User (if it needs to impersonate other service accounts for tools).
Crucially, it might need roles related to Agent Builder or Agent Engine, especially if your agent manages sessions or interacts with other Agent Engine features. Look for roles like Agent Builder User or custom roles that grant permissions for aiplatform.sessions.* and aiplatform.reasoningEngines.*.
If in doubt for testing purposes, temporarily grant Project Editor to the service account (then narrow down permissions for production).
Redeploy the agent after updating permissions. IAM changes can take a few minutes to propagate, but to be sure, redeploying the Reasoning Engine ensures it picks up the new permissions.
2. Vertex AI Agent Engine API Not Enabled:
Problem: Even if you have permissions, the specific API endpoint that vertex_ai_session_service calls might not be enabled in your project.
Solution:
Go to APIs & Services > Enabled APIs & Services in your Google Cloud Console.
Search for and ensure Vertex AI API is enabled.
Also, specifically look for anything related to ""Agent Engine"" or ""Agent Builder"" and ensure it's enabled. (As of current versions, Vertex AI API usually covers this, but it's worth a double-check if new specific APIs emerge).
Michelle Brain Manager • 11 months ago
3. Mismatch in Project ID or Location:
Problem: Your client-side code that calls create_session might be trying to create a session in a different project or region than where the Reasoning Engine is actually deployed or where your session service is configured.
Solution:
Double-check that the project and location arguments when initializing your VertexAiSessionService match the project and region where your reasoningEngine is deployed.
Example from quickstart:
Python
from google.adk.sessions import VertexAiSessionService
from google.adk.runners import RemoteRunner
import vertexai
PROJECT_ID = ""your-actual-project-id""
LOCATION = ""us-central1"" # Or wherever your agent is deployed
REASONING_ENGINE_ID = ""XXXXXXXXX"" # From your successful deployment link
vertexai.init(project=PROJECT_ID, location=LOCATION)
remote_session_service = VertexAiSessionService(
project=PROJECT_ID,
location=LOCATION
)
runner = RemoteRunner(
reasoning_engine_id=REASONING_ENGINE_ID,
session_service=remote_session_service
)
Verify that PROJECT_ID and LOCATION here precisely match what was used when deploying the Reasoning Engine itself.
4. Issues with the reasoningEngineId or AgentApp ID:
Michelle Brain Manager • 11 months ago
Problem: While you said you get a link, there could be a subtle mismatch if you're trying to explicitly define the AgentApp ID or reasoningEngineId when creating the session if your ADK runner setup implicitly expects something else.
Solution: Ensure the reasoning_engine_id you're passing to RemoteRunner is the exact, full ID (e.g., projects/YOUR-ID/locations/us-central1/reasoningEngines/YOUR-ID) or just the YOUR-ID part, depending on how the ADK SDK expects it. The quickstart usually just wants the final ID.
Debugging Steps:
Print api_response: The error TypeError: 'HttpResponse' object is not subscriptable means api_response is not a dict. If you were developing this yourself, you'd add a print statement before line 92 in vertex_ai_session_service.py to see what api_response actually is. Since it's a library, you can't easily do this.
Use gcloud CLI or REST API: Try to perform a simple session creation call using the gcloud CLI or the raw Vertex AI API (e.g., via curl or Python requests) for your production agent's Reasoning Engine.
For example: gcloud ai reasoning-engines sessions create --reasoning-engine=YOUR_RE_ID --location=YOUR_LOCATION
This might give you a clearer error message than the TypeError you're seeing through the ADK SDK. A direct gcloud command failing with a 403 Forbidden or 401 Unauthorized would confirm a permissions issue.
Check Cloud Logging: Go to Logging > Logs Explorer in the Google Cloud Console. Filter by your project and look for logs from Vertex AI or Reasoning Engine around the time you tried to create the session. A failed API call would usually leave a detailed log entry with a specific error code (like 403, 401, 400). This is often the most revealing source of truth.
It's highly probable this is an IAM permission issue with the service account associated with your production Reasoning Engine deployment, or a missing API enablement. We hope this helps and good luck!
Alex Capellán • 11 months ago
Thank you everybody. The main problem is a compatibility issue.
VertexAiSessionService doesn't work properly with google-genai==1.21.1.
If anyone else has this issue just fix it to 1.20.