Skip to content

Conversation

@sanjeevamk1
Copy link

@sanjeevamk1 sanjeevamk1 commented Jan 21, 2026

Please ensure you have read the contribution guide before creating a pull request.

Link to Issue or Description of Change

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

Problem:
For token streaming when akd agent is exposed with to_a2a

Solution:
Added streaming_mode in to_a2a so user can select streaming while exposing the agent

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sanjeevamk1, 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 enhances the to_a2a utility by integrating streaming support, allowing for more dynamic and efficient handling of agent responses. By introducing a StreamingMode and a configurable request converter, users can now specify how data is streamed when an ADK agent is converted into an A2A Starlette application, providing greater flexibility for interactive and real-time agent interactions.

Highlights

  • Streaming Mode Introduction: Introduced a new StreamingMode enum to control how agent responses are streamed.
  • Configurable Request Converter: Added a new experimental function create_request_converter that allows generating a request converter configured with a specific StreamingMode.
  • Streaming Support in to_a2a: The to_a2a utility function now accepts a streaming_mode parameter, enabling the configuration of streaming behavior when converting an ADK agent to an A2A Starlette application.
  • Executor Configuration Update: The A2aAgentExecutor within to_a2a is now initialized with an A2aAgentExecutorConfig, which incorporates the streaming-aware request converter.

🧠 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
Copy link
Collaborator

adk-bot commented Jan 21, 2026

Response from ADK Triaging Agent

Hello @sanjeevamk1, thank you for creating this PR!

To help reviewers understand and evaluate your contribution, could you please fill out the pull request template in the description? Specifically, please provide the following:

  • Link to Issue or Description of Change: Please either link to the relevant issue or provide a description of the problem and your solution.
  • Testing Plan: Describe the tests you ran to verify your changes, including any unit tests or manual end-to-end tests.
  • Checklist: Please fill out the checklist to confirm you've followed the contribution guidelines.

This information is crucial for an efficient review process. You can find more details in our contribution guide.

Thanks!

@adk-bot adk-bot added the live [Component] This issue is related to live, voice and video chat label Jan 21, 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 introduces streaming support for the to_a2a function. The implementation approach is sound, but I've identified a critical issue with a shadowed import that will likely lead to runtime failures. Additionally, there's an opportunity to improve maintainability by addressing significant code duplication in the new request converter. I've also pointed out a minor typo. Please review my comments for details.

from pydantic import BaseModel

from ...agents.run_config import RunConfig,StreamingMode
from ...runners import RunConfig
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This import of RunConfig from ...runners shadows the one imported from ...agents.run_config on the previous line. The RunConfig from ...agents.run_config is required for the streaming_mode parameter introduced in this PR. This shadowing will cause a runtime error because the RunConfig from ...runners likely does not support streaming_mode. This line should be removed.

Comment on lines +121 to +161
def create_request_converter(
streaming_mode: StreamingMode = StreamingMode.NONE
) -> A2ARequestToAgentRunRequestConverter:
"""Creates a request converter with specified streaming mode.
Args:
streaming_mode: The streaming mode to use for the agent execution.
Returns:
A Converter function configured with the specified streaming mode.
"""
def converter(
request: RequestContext,
part_converter: A2APartToGenAIPartConverter = convert_a2a_part_to_genai_part,
)-> AgentRunRequest:

if not request.message:
raise ValueError('Request message cannot be None')

custom_metadata = {}
if request.metadata:
custom_metadata['a2a_metadata'] = request.metadata

output_parts = []
for a2a_part in request.message.parts:
genai_parts = part_converter(a2a_part)
if not isinstance(genai_parts, list):
genai_parts = [genai_parts] if genai_parts else []
output_parts.extend(genai_parts)

return AgentRunRequest(
user_id=_get_user_id(request),
session_id=request.context_id,
new_message=genai_types.Content(
role='user',
parts=output_parts,
),
run_config=RunConfig(streaming_mode=streaming_mode, custom_metadata=custom_metadata),
)

return converter
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The new converter function defined inside create_request_converter is almost identical to the existing convert_a2a_request_to_agent_run_request function. This introduces significant code duplication, which makes the code harder to maintain. Please consider refactoring to remove this duplication. For example, the common logic could be extracted into a private helper function, or convert_a2a_request_to_agent_run_request could be updated to use this new factory.

Comment on lines +130 to 137
executer_config = A2aAgentExecutorConfig(
request_converter=create_request_converter(streaming_mode=streaming_mode)
)

agent_executor = A2aAgentExecutor(
runner=runner or create_runner,
config=executer_config,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

There is a typo in the variable name executer_config on lines 130 and 136. It should be executor_config.

Suggested change
executer_config = A2aAgentExecutorConfig(
request_converter=create_request_converter(streaming_mode=streaming_mode)
)
agent_executor = A2aAgentExecutor(
runner=runner or create_runner,
config=executer_config,
)
executor_config = A2aAgentExecutorConfig(
request_converter=create_request_converter(streaming_mode=streaming_mode)
)
agent_executor = A2aAgentExecutor(
runner=runner or create_runner,
config=executor_config,
)

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

Labels

live [Component] This issue is related to live, voice and video chat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Approval mechanism to enable rich human in the loop experiences

2 participants