Skip to content

INVALID_ARGUMENT in VertexAiSessionService during A2A call due to UUID session ID #2727

Closed

Description

@ftnext

Describe the bug
A 400 INVALID_ARGUMENT error with the message "Invalid Session resource name" occurs when an agent using VertexAiSessionService is called from another agent via A2A (Agent-to-Agent) communication.
This issue does not occur when interacting with the agent without using A2A.

To Reproduce
Steps to reproduce the behavior:

  1. Create an agent that utilizes VertexAiSessionService.
  2. From a different agent, attempt to connect to the first agent using A2A.
  3. Initiate a conversation.
  4. See the following error:
400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'List of found errors:\t1.Field: name; Message: Invalid Session resource name.\t', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'name', 'description': 'Invalid Session resource name.'}]}]}}}

Expected behavior
The A2A connection should be established successfully without any errors, and a new session should be created in the VertexAiSessionService-backed agent.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: Debian 13 (Using python docker image)
  • Python version(python -V): 3.13.7
  • ADK version(pip show google-adk): 1.12.0

Model Information:
gemini-2.5-pro

Additional context
The root cause appears to be a mismatch in session ID formats.

Based on the source code, the A2A SendMessageRequest in remote_a2a_agent.py uses a UUID as the session ID.

a2a_request = SendMessageRequest(
id=str(uuid.uuid4()),

return SendMessageRequest(
id=str(uuid.uuid4()),

However, when the receiving agent's VertexAiSessionService tries to create the session, it passes this UUID directly to the Vertex AI API.

get_session_api_response = await api_client.async_request(
http_method='GET',
path=f'reasoningEngines/{reasoning_engine_id}/sessions/{session_id}',
request_dict={},
)

The Vertex AI API seems to expect a numeric ID for the session resource name, not a UUID. This causes the "Invalid Session resource name" error.

This can be verified by sending a request with a UUID-formatted session ID directly to the Vertex AI API, which reproduces the error:

curl -X GET -H "Authorization: Bearer $(gcloud auth print-access-token)" "https://<location>-aiplatform.googleapis.com/v1beta1/projects/<our-project>/locations/<location>/reasoningEngines/<engine-id>/sessions/7e56773c-8968-4fe5-97c0-cc8d14e200e1"
{
  "error": {
    "code": 400,
    "message": "List of found errors:\t1.Field: name; Message: Invalid Session resource name.\t",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "name",
            "description": "Invalid Session resource name."
          }
        ]
      }
    ]
  }
}

Activity

  1. added
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Aug 26, 2025
  2. added theissue type on Aug 26, 2025
  3. added
    a2a[Component] This issue is related a2a support inside ADK.
    and removed
    services[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc
    on Nov 4, 2025
  4. surajksharma07 commented on Dec 3, 2025

    @surajksharma07
    Collaborator

    @ftnext This issue was fixed in ADK v1.19.0 (October 2025, commit 2158b3c).

    The root cause was UUID-format session IDs from A2A message_id being passed to VertexAI API, which expects specific session resource name format.

    The fix ensures proper context_id → session_id mapping in request_converter.py (line 122).

    Users experiencing this error should upgrade to ADK v1.19.0 or later: pip install --upgrade google-adk>=1.19.0

    Thanks!

  5. added
    answered[Status] This issue has been answered by the maintainer
    on Dec 3, 2025
  6. nikunjshantiairasia commented on Dec 17, 2025

    @nikunjshantiairasia

    I am still seeing this issue in 1.21 when using agent starter pack with a2a base

  7. surajksharma07 commented on Dec 17, 2025

    @surajksharma07
    Collaborator

    @nikunjshantiairasia The context_id extraction fix (commit 2158b3c) is included in v1.21.0.

    However, there are edge cases where UUID session IDs can still be generated - specifically when there's no existing context_id in metadata (first A2A call in a new conversation).

    Can you share the full error traceback and your agent configuration?

    Also confirm if this happens on the first A2A message or on subsequent messages in the conversation.

    If it's the initial message, the issue might be that context_id is None and falls back to message_id (UUID), which VertexAI rejects.

    A quick workaround is to pre-populate context_id in the A2A request metadata with a VertexAI-compatible session ID format before the first call, or use InMemorySessionService instead of VertexAiSessionService for A2A agents.

  8. ftnext commented on Dec 18, 2025

    @ftnext
    ContributorAuthor

    @surajksharma07 Thank you for working on this issue.

    This issue is still reproducible in ADK 1.21.0.
    Please re-open this issue.

    I'll demonstrate with a sample.
    https://github.com/google/adk-python/tree/v1.21.0/contributing/samples/a2a_basic

    % adk web contributing/samples/
    
    % adk api_server --a2a --port 8001 contributing/samples/a2a_basic/remote_a2a --session_service_uri agentengine://60xxxxxxxxxxxxxxxxx
    

    When asking "Is 7 a prime number?", the prime agent is called via A2A.

    Image

    adk api_server log

    INFO:     127.0.0.1:56567 - "GET /a2a/check_prime_agent/.well-known/agent-card.json HTTP/1.1" 200 OK
    2025-12-18 10:07:59,866 - INFO - envs.py:47 - Loaded .env file for check_prime_agent at /.../adk-python/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/.env
    2025-12-18 10:07:59,867 - INFO - envs.py:47 - Loaded .env file for check_prime_agent at /.../adk-python/contributing/samples/a2a_basic/remote_a2a/check_prime_agent/.env
    2025-12-18 10:07:59,869 - INFO - agent_loader.py:129 - Found root_agent in check_prime_agent.agent
    2025-12-18 10:08:02,329 - INFO - task_manager.py:179 - Task not found or task_id not set. Creating new task for event (task_id: d6489151-437e-49ea-9543-e3eb8923d1a9, context_id: 01e8a9db-b093-47c1-9e89-3c0e7b321c12).
    2025-12-18 10:08:03,693 - INFO - _client.py:1740 - HTTP Request: GET https://us-central1-aiplatform.googleapis.com/v1beta1/projects/xxxxxxxxxx/locations/us-central1/reasoningEngines/60xxxxxxxxxxxxxxxxx/sessions/01e8a9db-b093-47c1-9e89-3c0e7b321c12/events "HTTP/1.1 400 Bad Request"
    2025-12-18 10:08:03,694 - ERROR - a2a_agent_executor.py:157 - Error handling A2A request: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}
    Traceback (most recent call last):
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/adk/a2a/executor/a2a_agent_executor.py", line 155, in execute
        await self._handle_request(context, event_queue)
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/adk/a2a/executor/a2a_agent_executor.py", line 196, in _handle_request
        session = await self._prepare_session(context, run_request, runner)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/adk/a2a/executor/a2a_agent_executor.py", line 291, in _prepare_session
        session = await runner.session_service.get_session(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        ...<3 lines>...
        )
        ^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/adk/sessions/vertex_ai_session_service.py", line 158, in get_session
        get_session_response, events_iterator = await asyncio.gather(
                                                ^^^^^^^^^^^^^^^^^^^^^
        ...<5 lines>...
        )
        ^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/vertexai/_genai/session_events.py", line 471, in list
        await self._list(name=name, config=config),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/vertexai/_genai/session_events.py", line 433, in _list
        response = await self._api_client.async_request(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            "get", path, request_dict, http_options
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/genai/_api_client.py", line 1434, in async_request
        result = await self._async_request(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
            http_request=http_request, http_options=http_options, stream=False
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/genai/_api_client.py", line 1367, in _async_request
        return await self._async_retry(  # type: ignore[no-any-return]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            self._async_request_once, http_request, stream
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        )
        ^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/tenacity/asyncio/__init__.py", line 111, in __call__
        do = await self.iter(retry_state=retry_state)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/tenacity/asyncio/__init__.py", line 153, in iter
        result = await action(retry_state)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/tenacity/_utils.py", line 99, in inner
        return call(*args, **kwargs)
      File "/.../adk-python/.venv/lib/python3.13/site-packages/tenacity/__init__.py", line 420, in exc_check
        raise retry_exc.reraise()
              ~~~~~~~~~~~~~~~~~^^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/tenacity/__init__.py", line 187, in reraise
        raise self.last_attempt.result()
              ~~~~~~~~~~~~~~~~~~~~~~~~^^
      File "/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 449, in result
        return self.__get_result()
               ~~~~~~~~~~~~~~~~~^^
      File "/opt/homebrew/Cellar/python@3.13/3.13.5/Frameworks/Python.framework/Versions/3.13/lib/python3.13/concurrent/futures/_base.py", line 401, in __get_result
        raise self._exception
      File "/.../adk-python/.venv/lib/python3.13/site-packages/tenacity/asyncio/__init__.py", line 114, in __call__
        result = await fn(*args, **kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/genai/_api_client.py", line 1347, in _async_request_once
        await errors.APIError.raise_for_async_response(client_response)
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/genai/errors.py", line 203, in raise_for_async_response
        await cls.raise_error_async(status_code, response_json, response)
      File "/.../adk-python/.venv/lib/python3.13/site-packages/google/genai/errors.py", line 225, in raise_error_async
        raise ClientError(status_code, response_json, response)
    google.genai.errors.ClientError: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'Request contains an invalid argument.', 'status': 'INVALID_ARGUMENT'}}
    INFO:     127.0.0.1:56567 - "POST /a2a/check_prime_agent HTTP/1.1" 200 OK
    
  9. surajksharma07 commented on Dec 18, 2025

    @surajksharma07
    Collaborator

    @ftnext Thanks for the detailed reproduction with the a2a_basic sample.

    You're correct - the issue still exists in v1.21.0.

    The original fix in v1.19.0 addressed using context_id instead of message_id, but didn't handle the case where context_id itself is a UUID (generated by the A2A protocol when no context exists).

    The root cause: On the first A2A call, there's no existing context_id in metadata (remote_a2a_agent.py:358-368), so context_id=None is passed.

    The A2A server library then generates a new UUID as context_id (standard A2A protocol behavior), which becomes "01e8a9db-b093-47c1-9e89-3c0e7b321c12" in your log.

    This UUID is then used as session_id for VertexAI (request_converter.py:111), which VertexAI rejects.

    The workaround for now is to use InMemorySessionService instead of VertexAiSessionService for A2A agents, or implement a custom request converter that transforms UUID context_ids into VertexAI-compatible session IDs before calling get_session.

    A proper fix would require the A2A executor to detect VertexAiSessionService and handle UUID context_ids appropriately.

  10. 3 remaining items

  11. surajksharma07 commented on Dec 18, 2025

    @surajksharma07
    Collaborator

    @DeanChensj Please have a look into it.

  12. removed their assignment
    on Dec 18, 2025
  13. added
    answered[Status] This issue has been answered by the maintainer
    on Dec 19, 2025
  14. ftnext commented on Jan 31, 2026

    @ftnext
    ContributorAuthor

    @DeanChensj @surajksharma07 Please review & merge #4340

  15. removed
    answered[Status] This issue has been answered by the maintainer
    on Feb 2, 2026
  16. adk-bot commented on Mar 6, 2026

    @adk-bot
    Collaborator

    This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.

  17. added
    stale[Status] Issues which have been marked inactive since there is no user response
    on Mar 6, 2026
  18. ftnext commented on Mar 6, 2026

    @ftnext
    ContributorAuthor

    @DeanChensj @surajksharma07 Please review & merge #4340

  19. surajksharma07 commented on Mar 6, 2026

    @surajksharma07
    Collaborator

    @seanzhou1023 Please have a look into it once.

  20. removed
    stale[Status] Issues which have been marked inactive since there is no user response
    on Mar 7, 2026
  21. ftnext commented on Mar 8, 2026

    @ftnext
    ContributorAuthor

    @surajksharma07 @seanzhou1023 Thanks so much for taking a look at this issue and the PR.

    I’ve now resolved the merge conflicts in the PR: #4340 (comment)

    I also want to emphasize the impact: this has effectively blocked using VertexAiSessionService with A2A for more than six months, which has been extremely disruptive for us in practice.
    We’ve been heavily affected by this, so we’d really appreciate prioritizing a review/merge when possible.

  22. ftnext commented on Apr 18, 2026

    @ftnext
    ContributorAuthor

    Re-tested on ADK 1.31.0 and this no longer reproduces #2727 (comment)

    RemoteA2aAgent completed successfully,

    Image

    and Vertex AI Agent Engine created a session with a UUID session ID.

    Image

    So this looks fixed now and can probably be closed.
    Maybe e1913a6 on v1.29.0 fixed.
    Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

a2a[Component] This issue is related a2a support inside ADK.needs review[Status] The PR/issue is awaiting review from the maintainer

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions