Skip to content

feat: add a2a_state_forwarding sample - #5356

Closed
Koichi73 wants to merge 2 commits into
google:mainfrom
Koichi73:sample/a2a-state-forwarding
Closed

Koichi73 wants to merge 2 commits into
google:mainfrom
Koichi73:sample/a2a-state-forwarding

Conversation

@Koichi73

Copy link
Copy Markdown
Contributor

Summary

  • Add a sample demonstrating how to forward client-side session.state to a remote ADK agent over the A2A protocol via request metadata
  • Client side: a RequestInterceptor copies whitelisted state keys into A2A request metadata
  • Server side: a before_agent_callback reads run_config.custom_metadata['a2a_metadata'] and injects the values back into session state so that instruction template placeholders (e.g. {user_name}) resolve correctly

Relates to #3098

Test plan

  • Start the remote agent: adk api_server --a2a --port 8001 contributing/samples/a2a_state_forwarding/remote_a2a
  • Start the client: adk web contributing/samples/
  • Select the a2a_state_forwarding agent and send "greet me" → confirms Hello Alice! How are you doing today? is returned
  • Remove user_name from ALLOWED_FORWARD_KEYS → confirms the template remains unresolved (whitelist is effective)

Demonstrate how to forward client-side session state to a remote ADK
agent over the A2A protocol via request metadata. The client uses a
RequestInterceptor to copy whitelisted state keys into A2A metadata,
and the server injects them back into session state through a
before_agent_callback so that instruction template placeholders like
{user_name} resolve correctly.
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Apr 16, 2026
@rohityan rohityan self-assigned this Apr 16, 2026
@rohityan rohityan added the community repo [Community] FRs/issues well suited for google/adk-python-community repository label Apr 16, 2026
@Koichi73

Copy link
Copy Markdown
Contributor Author

Hi @rohityan, thanks for the triage! I noticed the community repo label was added — could you clarify the intent? A couple of concerns about moving this to google/adk-python-community:

  1. This PR follows the exact pattern of the existing A2A samples already living in contributing/samples/ (a2a_basic, a2a_auth, a2a_human_in_loop, a2a_root). Splitting one A2A sample off into a separate repo would fragment the discovery experience for users learning A2A.
  2. adk-python-community is structured around plugins / services / tools / deployment modules — there isn't a natural home for a sample agent there.

Would you reconsider keeping this here alongside the other A2A samples? If there's a specific concern with the PR I'm happy to address it. Thanks!

copybara-service Bot pushed a commit that referenced this pull request Sep 9, 2026
Merge #5356

Adds a sample demonstrating how to forward client-side session state to a remote ADK agent over A2A via request metadata.

PiperOrigin-RevId: 978607602
@adk-bot

adk-bot commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Koichi73 for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 1b28de4.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Sep 9, 2026
@adk-bot adk-bot closed this Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community repo [Community] FRs/issues well suited for google/adk-python-community repository core [Component] This issue is related to the core interface and implementation merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants