The Agentspace (Gemini Enterprise) Agent gets error when registered with authorization
Hi!
In agentspace, when calling agent with registered authorization, I am getting the following error:
{ "error": { "code": 400, "message": "Agent finished execution without providing any response.", "status": "FAILED_PRECONDITION", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "AGENT_ENGINE_FAILED_PRECONDITION", "domain": "discoveryengine.googleapis.com" }, { "@type": "type.googleapis.com/google.rpc.RequestInfo", "requestId": "assist_token:M8gKCwjBotbIBhC0n-RUEiQ2OTE0ZjUyZi0wMDAwLTJjZGItOTQ5Ny01ODI0MjlhOGRkOTg" } ] } }
Agent was deployed by: adk deploy agent_engine ...
I tried multiple combinations of google-adk and google-cloud-aiplatform libraries. Nothing worked.
We are using eu location for Agentspace. ADK agent is in europe-west1 location.
Would be helpful if anyone knows the reason and of this.
Same issue here. Did you add the permission Discovery Engine User to the service account of your agent? I suspect it's an IAM issue. What does the logs say?
This is my log entry: Traceback (most recent call last): File "/usr/local/lib/python3.11/threading.py", line 1045, in _bootstrap_inner self.run() File "/usr/local/lib/python3.11/threading.py", line 982, in run self._target(*self._args, **self._kwargs) File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.11/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 1042, in _asyncio_thread_main asyncio.run(_invoke_agent_async()) File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.11/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 1015, in _invoke_agent_async for event in runner.run_async( TypeError: 'async_generator' object is not iterable
Permissions are set like You described and didnt help.
logs: DEFAULT 2025-11-13T17:32:02.559711Z [16] INFO: 169.254.169.126:11570 - "POST /api/stream_reasoning_engine HTTP/1.1" 200 OK DEFAULT 2025-11-13T17:32:02.566813Z [16] ERROR: Task exception was never retrieved DEFAULT 2025-11-13T17:32:02.566868Z future: <Task finished name='Task-38' coro=<<async_generator_athrow without name>()> exception=RuntimeError('Attempted to exit cancel scope in a different task than it was entered in')> DEFAULT 2025-11-13T17:32:02.566883Z + Exception Group Traceback (most recent call last): DEFAULT 2025-11-13T17:32:02.566889Z | File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit DEFAULT 2025-11-13T17:32:02.566895Z | raise BaseExceptionGroup( DEFAULT 2025-11-13T17:32:02.566910Z | BaseExceptionGroup: unhandled errors in a TaskGroup (2 sub-exceptions) DEFAULT 2025-11-13T17:32:02.566916Z +-+---------------- 1 ---------------- DEFAULT 2025-11-13T17:32:02.566924Z | Traceback (most recent call last): DEFAULT 2025-11-13T17:32:02.566930Z | File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 409, in handle_request_async DEFAULT 2025-11-13T17:32:02.566935Z | await self._handle_post_request(ctx) DEFAULT 2025-11-13T17:32:02.566940Z | File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 278, in _handle_post_request DEFAULT 2025-11-13T17:32:02.566945Z | response.raise_for_status() DEFAULT 2025-11-13T17:32:02.566949Z | File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/httpx/_models.py", line 829, in raise_for_status DEFAULT 2025-11-13T17:32:02.566958Z | raise HTTPStatusError(message, request=request, response=self) DEFAULT 2025-11-13T17:32:02.566966Z | httpx.HTTPStatusError: Client error '401 Unauthorized' for url 'https://mcp.hubspot.com/' DEFAULT 2025-11-13T17:32:02.566970Z | For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/401 DEFAULT 2025-11-13T17:32:02.566974Z +---------------- 2 ---------------- DEFAULT 2025-11-13T17:32:02.566983Z | Traceback (most recent call last): DEFAULT 2025-11-13T17:32:02.566988Z | File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/mcp/client/streamable_http.py", line 502, in streamablehttp_client DEFAULT 2025-11-13T17:32:02.566992Z | yield ( DEFAULT 2025-11-13T17:32:02.566996Z | GeneratorExit DEFAULT 2025-11-13T17:32:02.567001Z +------------------------------------
ok looks like this is a different issue, which includes authorization to the mcp server at hubspot. Have you created oauth credentials and set the param when registering the agent in GE?
"adkAgentDefinition": { "toolSettings": { "toolDescription": "A tool to perform Create, Read, Update, and Delete operations on ServiceNow records." }, "provisionedReasoningEngine": { "reasoningEngine": "projects/xxxx/locations/us-central1/reasoningEngines/xxxxxx" }, "authorizations": [ "projects/xxxx/locations/global/authorizations/your-auth-id" ] },
my issue is related to "Warning: there are non-text parts in the response: ['function_call', 'thought_signature']"
Yes, I did
I made a new deployment according to https://google.github.io/adk-docs/deploy/agent-engine/.
I set up the authorization and registered agent again in Agentspace.
I am still getting same error in agentspace:
{ "error": { "code": 400, "message": "Agent finished execution without providing any response.", "status": "FAILED_PRECONDITION", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "AGENT_ENGINE_FAILED_PRECONDITION", "domain": "discoveryengine.googleapis.com" }, { "@type": "type.googleapis.com/google.rpc.RequestInfo", "requestId": "assist_token:M8gKCwjt-uHIBhDwqZdwEiQ2OTE4MDAzYi0wMDAwLTI3MmQtYjM4Zi1kNDNhMmNjYjU2MGY" } ] } }
logs looks:
ERROR 2025-11-15T13:17:33.170787229Z [protoPayload.serviceName: Discovery Engine API] [protoPayload.methodName: StreamAssist] [protoPayload.resourceName: projects/626236461221/locations/eu/collections/default_collection/engines/agentspace-pilot_1741351982079/assistants/default_assistant] [protoPayload.authenticationInfo.principalEmail: [email protected]] Agent finished execution without providing any response.; Failed to get AssistAnswer. ERROR 2025-11-15T13:17:33.170787229Z [protoPayload.serviceName: Discovery Engine API] [protoPayload.methodName: StreamAssist] [protoPayload.resourceName: projects/626236461221/locations/eu/collections/default_collection/engines/agentspace-pilot_1741351982079/assistants/default_assistant] [protoPayload.authenticationInfo.principalEmail: [email protected]] Agent finished execution without providing any response.; Failed to get AssistAnswer. DEFAULT 2025-11-15T13:17:33.905417Z [1] ERROR: Error during async stream generation: Session not found: 639fe6d5-0fbf-46a0-9228-e1c0ec24b0f9 { "textPayload": "[1] ERROR: Error during async stream generation: Session not found: 639fe6d5-0fbf-46a0-9228-e1c0ec24b0f9", "insertId": "69187d6d000dd0c9daaebf71", "resource": { "type": "aiplatform.googleapis.com/ReasoningEngine", "labels": { "resource_container": "626236461221", "location": "europe-west1", "reasoning_engine_id": "2288901734052921344" } }, "timestamp": "2025-11-15T13:17:33.905417Z", "logName": "projects/snbx-btaii-cm/logs/aiplatform.googleapis.com%2Freasoning_engine_stderr", "receiveTimestamp": "2025-11-15T13:17:33.908775676Z" } ERROR 2025-11-15T13:17:33.905478Z Traceback (most recent call last): File "/code/app/api/factory/python_file_api_builder.py", line 473, in _async_stream_json_generator async for chunk in output: File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/vertexai/agent_engines/templates/adk.py", line 1129, in streaming_agent_run_with_events async for event in runner.run_async( File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/google/adk/runners.py", line 443, in run_async async for event in agen: File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/google/adk/runners.py", line 380, in _run_with_trace raise ValueError(message) ValueError: Session not found: 639fe6d5-0fbf-46a0-9228-e1c0ec24b0f9 { "textPayload": "Traceback (most recent call last):\n File "/code/app/api/factory/python_file_api_builder.py", line 473, in _async_stream_json_generator\n async for chunk in output:\n File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/vertexai/agent_engines/templates/adk.py", line 1129, in streaming_agent_run_with_events\n async for event in runner.run_async(\n File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/google/adk/runners.py", line 443, in run_async\n async for event in agen:\n File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/google/adk/runners.py", line 380, in _run_with_trace\n raise ValueError(message)\nValueError: Session not found: 639fe6d5-0fbf-46a0-9228-e1c0ec24b0f9", "insertId": "69187d6d000dd1066a10863d", "resource": { "type": "aiplatform.googleapis.com/ReasoningEngine", "labels": { "resource_container": "626236461221", "reasoning_engine_id": "2288901734052921344", "location": "europe-west1" } }, "timestamp": "2025-11-15T13:17:33.905478Z", "severity": "ERROR", "logName": "projects/snbx-btaii-cm/logs/aiplatform.googleapis.com%2Freasoning_engine_stderr", "receiveTimestamp": "2025-11-15T13:17:33.908775676Z" }
I am facing the same error. Did anyone find the solution.
File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.11/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 1015, in _invoke_agent_async for event in runner.run_async( TypeError: 'async_generator' object is not iterable
I'm facing this issue even with a simple agent that doesn't use authorization. The agent was working fine until Thursday (13-Nov-2025), and it suddenly started failing with this error.
deploy.py requirements=[ "google-adk (>=0.0.2)", "google-cloud-aiplatform[agent_engines] (>=1.91.0,!=1.92.0)", "google-genai (>=1.5.0,<2.0.0)", "pydantic (>=2.10.6,<3.0.0)", "absl-py (>=2.2.1,<3.0.0)", ],
Issue: File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.12/lib/python3.12/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 1015, in _invoke_agent_async for event in runner.run_async( ^^^^^^^^^^^^^^^^^ TypeError: 'async_generator' object is not iterable
What I’ve tried so far: Upgraded the Google ADK version Deleted the Cloud Storage bucket manually Created and used a new Cloud Storage bucket Created a new simple ADK agent and deployed it Deployed existing agents after renaming Removing all the agent related dependencies and redeployed
@anton-hajdu This is a compound bug affecting Agent Engine deployments.
The primary issue is in the vertexai package template (vertexai/preview/reasoning_engines/templates/adk.py:1015) which uses for event in runner.run_async() instead of async for.
This needs to be fixed in the vertexai package.
we are looking more into it.
Additionally, ADK's deployment template should initialize VertexAiSessionService when creating the AdkApp for Agent Engine to prevent "Session not found" errors.
The session service needs to be configured with the proper project and location parameters to work with Agentspace.
Thanks!
@xuanyang15 Please have a look into it.
So there is this error:
Traceback (most recent call last): File "/usr/local/lib/python3.11/threading.py", line 1045, in _bootstrap_inner self.run() File "/usr/local/lib/python3.11/threading.py", line 982, in run self._target(*self._args, **self._kwargs) File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.11/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 1042, in _asyncio_thread_main asyncio.run(_invoke_agent_async()) File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run return runner.run(main) ^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete return future.result() ^^^^^^^^^^^^^^^ File "/home/appuser/.cache/pypoetry/virtualenvs/reasoning-engine-assembly-service-MATOk_fk-py3.11/lib/python3.11/site-packages/vertexai/preview/reasoning_engines/templates/adk.py", line 1015, in _invoke_agent_async for event in runner.run_async( TypeError: 'async_generator' object is not iterable
But before that I get warnings about
WARNING - types.py:6324 - Warning: there are non-text parts in the response: ['thought_signature'], returning concatenated text result from text parts. Check the full candidates.content.parts accessor to get the full model response
@bluechipamsterdam Thank you for the additional details.The 'thought_signature' warning indicates your agent is using BuiltInPlanner/thinking features, and Agent Engine is failing to process these non-text response parts correctly - this explains why the error occurs before the async generator issue. This is a compound bug: both the response processing for thinking features and the VertexAiSessionService initialization need fixes.
The immediate workaround: avoid using BuiltInPlanner when deploying to Agent Engine, or ensure your deployment explicitly initializes VertexAiSessionService with your project and location. We're looking more into it as it affects all Agentspace deployments using advanced planning features.
@surajksharma07 It seems like this is exactly my issue and i have been able to reproduce it in my dev environment by using the session service as such: adk web --session_service_uri=agentengine://url-ReasoningEngine
The session gets created and then immediately after it throws two errors: google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}} and then the asyncio iterable object error in the log.
Explicitly initializing VertexAiSessionService and avoiding BuiltInPlanner have not worked yet, the problem remains. Do I also need to create the session manually before, and if so is this done in a callback?
@bluechipamsterdam The 400 INVALID_ARGUMENT error you're seeing is actually the root issue - Agentspace is sending session state/context that the Agent Engine can't handle. When you use --session_service_uri=agentengine://... locally, it's trying to use Agent Engine's session service which expects sessions to be created through Agentspace, not locally.
For the VertexAiSessionService initialization, you need to add it in your agent's deployment code (the agent file itself, not the deploy script). Try initializing it when creating your AdkApp like this: session_service = VertexAiSessionService(project="your-project", location="europe-west1") and pass it to your app. However, the underlying issue is that the vertexai template code has the for vs async for bug, which is blocking proper async execution regardless of session initialization. The real fix needs to come from the vertexai package team (@xuanyang15 is looking into it). Until then, agents with authorization or thinking features won't work properly in Agentspace unfortunately. Manual session creation won't help here since Agentspace manages sessions automatically - the problem is in how the deployed agent processes them.
Thanks for your time and patience!
Hello, @surajksharma07 , Your workaround is working. The Authorized Agent now works in Gemini Enterprise!
Here is my deployment code with properly initialized VertexAiSessionService.
Thank You
Looking forward for Your fix
from agent import root_agent from google.adk.sessions import VertexAiSessionService import vertexai
vertexai.init( project="your-project", location="europe-west1", staging_bucket="gs://your-bucket", )
vertex_service = VertexAiSessionService( project="your-project", location="europe-west1", )
from vertexai import agent_engines
app = agent_engines.AdkApp( agent=root_agent, enable_tracing=True, session_service_builder=lambda: vertex_service )
remote_app = agent_engines.create( agent_engine=app, requirements=[ "google-cloud-aiplatform[adk,agent_engines]" ] )
print(f"Deployment finished!") print(f"Resource Name: {remote_app.resource_name}")
@anton-hajdu Great to hear the workaround is working for you. Thanks for sharing your deployment code - it will help others facing the same issue.
To summarize for everyone:
Temporary Workaround (Working):
- Initialize
VertexAiSessionServicein your deployment code - Pass it to
AdkAppviasession_service_builderparameter - See @anton-hajdu's code above for a complete example
Permanent Fix (In Progress):
We're coordinating with the vertexai package team to fix the underlying async for bug in
vertexai/preview/reasoning_engines/templates/adk.py:1015.
@VenkateshM0631 @ashishjhacapgemini - Please try the workaround above. This should resolve the issue for agents with or without authorization.
we are looking more into it. Thanks everyone for your patience!
@surajksharma07 The workaround doesn't work for me. It feels to me as if Gemini is trying to query the agent before the session is created. Also I notice the user id from Gemini Enterprise to be generic "vais-query-reasoning-engine" regardless of the Google ID using it.
The playground always generates a new session, whereas one would expect (or configure) it to use a sessions for the same user to maintain memory... It would be great to have more control over this when in this particular scenario.
@anton-hajdu mind sharing your Agentspace registration script? We made so many changes to it over the last days that we might have broken it...
I ran into the same issue, and it turned out to be caused by the google-cloud-aiplatform version 1.126.0. You can try to downgrade the version to 1.125.0, I did and the error disappeared completely.
@ilia1229 The version downgrade confirms this is primarily a regression in google-cloud-aiplatform 1.126.0. Immediate Solutions
Option 1: Version Downgrade (Recommended) In your deployment requirements "google-cloud-aiplatform[agent_engines]==1.125.0" # Pin to 1.125.0
Option 2: Session Service Workaround (Partial Fix)
- Works for some users (@anton-hajdu)
- Doesn't work for others (@bluechipamsterdam)
- See @anton-hajdu's code above if downgrade isn't possible
@bluechipamsterdam Can you try downgrading to 1.125.0 and report if it resolves your issue?
This appears to be a google-cloud-aiplatform 1.126.0 regression in the vertexai template code, not an ADK bug.
The downgrade to 1.125.0 worked! BTW i noticed in the GCP interface there is new functionality to add agent engine agents through the interface.
@surajksharma07
The workaround not worked initially for me but after downgrade to 1.125.0 it worked. Thanks!
thanks @bluechipamsterdam and @VenkateshM0631 for confirming the fix.
The solution is confirmed: downgrade to google-cloud-aiplatform==1.125.0 resolves the issue.
This is a regression in version 1.126.0 of the google-cloud-aiplatform package (specifically in vertexai/preview/reasoning_engines/templates/adk.py with the async for bug).
Until 1.126.0 is patched upstream, please pin your deployment requirements to 1.125.0.
We'll coordinate with the google-cloud-aiplatform team to get 1.126.0 fixed and will update here when a patched version is available.