Skip to content

feat: add a2a_state_forwarding sample#5356

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

feat: add a2a_state_forwarding sample#5356
Koichi73 wants to merge 2 commits into
google:mainfrom
Koichi73:sample/a2a-state-forwarding

Conversation

@Koichi73
Copy link
Copy Markdown

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
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!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants