Skip to content

Conversation

ufJmacca
Copy link

@ufJmacca ufJmacca commented Oct 6, 2025

feat: Propagate A2A request metadata to InvocationContext

Fixes #3098

Description

This pull request introduces a new feature to propagate the metadata from an incoming Agent-to-Agent (A2A) request into the InvocationContext. This enhancement enables end-to-end traceability and allows developers to build more advanced logic within their agents based on request-specific metadata in a distributed multi-agent system.

Currently, any metadata sent as part of an A2A MessageSendParams is dropped during the conversion process and is not accessible within the agent's execution context. This change ensures that this valuable information is preserved and made available.

Key Changes:

  1. RunConfig Update: A new optional metadata field has been added to the RunConfig class to serve as a carrier for the metadata during the invocation setup.
  2. A2A Converter Update: The convert_a2a_request_to_adk_run_args function in the A2A converter has been updated to correctly extract the metadata from the RequestContext's request property.
  3. InvocationContext Update: A new a2a_metadata field has been added to the InvocationContext to store the metadata, making it accessible throughout the agent's execution.
  4. Runner Update: The _new_invocation_context method in the Runner now transfers the metadata from the RunConfig to the InvocationContext upon its creation.

Manual End-to-End Testing

Manual end-to-end testing was completed to verify the functionality in a real-world scenario. The details of the manual testing, including the setup, requests, and validation steps, can be found in the following repository:

https://github.com/ufJmacca/manual-A2A-request-metadata-propagation-to-InvocationContext

This change provides a critical enhancement for building robust and traceable distributed agent systems with the ADK.

Copy link

google-cla bot commented Oct 6, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Copy link

Summary of Changes

Hello @ufJmacca, 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 implements a crucial feature to propagate metadata from Agent-to-Agent (A2A) requests directly into the 'InvocationContext'. This ensures that valuable request-specific metadata, previously lost, is now preserved and accessible throughout an agent's execution. This enhancement significantly improves end-to-end traceability and enables developers to build more sophisticated, context-aware logic within their distributed multi-agent systems.

Highlights

  • RunConfig Enhancement: An optional 'metadata' field has been added to the 'RunConfig' class to serve as a carrier for A2A request metadata during invocation setup.
  • A2A Converter Update: The 'convert_a2a_request_to_adk_run_args' function now correctly extracts 'metadata' from the incoming A2A 'RequestContext' and passes it to the 'RunConfig'.
  • InvocationContext Extension: A new optional 'a2a_metadata' field has been introduced in the 'InvocationContext' to store the propagated A2A request metadata, making it accessible throughout the agent's execution.
  • Runner Integration: The '_new_invocation_context' method in the 'Runner' now transfers the 'metadata' from the 'RunConfig' to the 'InvocationContext' upon its creation, ensuring end-to-end propagation.
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.

Copy link

@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 introduces a new feature to propagate metadata from an incoming Agent-to-Agent (A2A) request into the InvocationContext. The changes are logical and correctly implemented across the necessary components: request_converter, RunConfig, InvocationContext, and runners. This enhancement will improve traceability in a multi-agent system. My review includes one suggestion to make the code slightly more concise and Pythonic.

@adk-bot
Copy link
Collaborator

adk-bot commented Oct 6, 2025

Response from ADK Triaging Agent

Hello @ufJmacca, thank you for creating this PR!

Before we can merge this PR, you need to sign our Contributor License Agreement (CLA). You can do so by following the instructions at https://cla.developers.google.com/.

Once you have signed the CLA, the "cla/google" check will pass, and we can proceed with the review.

Thanks!

@adk-bot adk-bot added bot triaged [Bot] This issue is triaged by ADK bot core [Component] This issue is related to the core interface and implementation labels Oct 6, 2025
@adk-bot adk-bot requested a review from Jacksunwei October 6, 2025 03:24
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot triaged [Bot] This issue is triaged by ADK bot 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.

feat: Propagate A2A request metadata to InvocationContext
2 participants