Skip to content

Conversation

@ftnext
Copy link
Contributor

@ftnext ftnext commented Jan 31, 2026

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
% pytest tests/unittests/a2a  # Python 3.13.8
======================== 254 passed, 204 warnings in 1.63s =========================

Manual End-to-End (E2E) Tests:

Fixed #2727 (comment) 's procedure

% adk web contributing/samples/
% adk api_server --a2a --port 8001 contributing/samples/a2a_basic/remote_a2a --session_service_uri agentengine://projects/.../locations/.../reasoningEngines/60...

2026-01-31 15:18:18,885 - INFO - task_manager.py:179 - Task not found or task_id not set. Creating new task for event (task_id: 3ee2f229-f181-4065-ace9-1f441e07ec88, context_id: ADK/check_prime_agent/A2A_USER_4bd49a87-b367-433c-827c-d68c27cb5c5b/4097040359593345024).
image

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

Problem:
A2A requests may carry a UUID context_id.
The server side treated that value as an ADK session_id and passed it to VertexAiSessionService, which rejects UUID session names.
This breaks the first A2A call for Vertex AI-backed sessions.

Solution:
Parse ADK-formatted context IDs (ADK/<app>/<user>/<session>) and only use the
session component when present.
Otherwise, treat the session as unset and create it via VertexAiSessionService, then return an ADK-formatted context ID in A2A responses so subsequent calls can resolve a valid session ID.
This prevents UUID values from being sent to Vertex AI.

A2A context IDs are now normalized to ADK/<app>/<user>/<session> so the session_id is always Vertex AI-compatible after the first call.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ftnext, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue where A2A requests with UUID-based context IDs were causing failures when interacting with Vertex AI-backed session services. The changes introduce a robust mechanism to parse and normalize A2A context IDs, ensuring that valid session identifiers are consistently used or created. This prevents UUIDs from being sent to Vertex AI, thereby resolving session creation and management problems and improving the reliability of A2A interactions.

Highlights

  • A2A Context ID Handling: Implemented logic to parse A2A context IDs, specifically extracting the session component from ADK-formatted IDs (ADK///). This ensures that only valid, non-UUID session IDs are passed to Vertex AI session services.
  • Session Creation and Normalization: Modified the session preparation process to explicitly create a new session via VertexAiSessionService if an incoming A2A request's context ID does not contain a valid, parsable session ID. Subsequently, all A2A responses will return a normalized ADK-formatted context ID, ensuring consistency for future interactions.
  • Event Context ID Updates: Updated the A2aAgentExecutor to use the newly generated or parsed ADK-formatted context ID (response_context_id) for all emitted TaskStatusUpdateEvent and TaskArtifactUpdateEvent events, ensuring event tracking aligns with the normalized session identifiers.
  • User ID Extraction Improvement: Enhanced the _get_user_id utility to first attempt extracting the user ID from an ADK-formatted context ID before falling back to constructing a user ID from the raw context ID.
  • Refactored Session Preparation: The _prepare_session method in A2aAgentExecutor was refactored to handle the creation of new sessions more robustly when an initial session ID is not provided or is invalid, preventing issues with Vertex AI's session naming conventions.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Jan 31, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively resolves an issue with A2A requests carrying UUID context_id values, which are incompatible with VertexAiSessionService. The solution correctly parses ADK-formatted context IDs, creates new sessions when necessary, and ensures that a valid, normalized context ID is propagated back to the client for subsequent calls. The logic is sound and the changes are well-supported by updated unit tests. I have one suggestion for a minor refactoring to improve code clarity and maintainability.

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

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

INVALID_ARGUMENT in VertexAiSessionService during A2A call due to UUID session ID

2 participants