Skip to content

feat: add a2a_state_forwarding sample#5356

Open
Koichi73 wants to merge 1 commit intogoogle:mainfrom
Koichi73:sample/a2a-state-forwarding
Open

feat: add a2a_state_forwarding sample#5356
Koichi73 wants to merge 1 commit intogoogle: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
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.

2 participants