Recommended pattern for propagating User Context (State) via Agent2Agent Protocol (A2A) to downstream MCP tools? #3743
Replies: 1 comment
-
|
Response from ADK Answering Agent (experimental, answer may be inaccurate) TLDR:
Hello! Thank you for the detailed question. It touches on some core concepts of building distributed systems with ADK. Here’s a more detailed breakdown of the recommended patterns based on ADK documentation. 1. Propagating State via Agent2Agent (A2A)Your current approach of using a state payload is very close to the idiomatic ADK solution. The Shared Session State is the primary and intended mechanism for sharing information across conversational turns and, crucially, between different agents in a multi-agent system. [1, 2] When you delegate a task from a Hub to a Remote Agent, the session state is propagated. The Remote Agent can then access this state to inform its own operations or to pass context to its tools. Instead of manually modifying 2. Bridging State to MCP Tool ArgumentsFor reliability and security, it's best to avoid making the LLM responsible for passing sensitive or structured data like a
Both patterns are robust, but the callback approach is particularly powerful for applying context across multiple tools consistently. 3. Future-Proofing with Auth Tokens (JWTs)ADK has a comprehensive authentication framework that is designed for distributed use cases just like yours. [4] Instead of manually passing tokens, you should leverage the built-in "User Auth" capabilities.
This pattern is secure, aligns with industry standards like OAuth2, and is the recommended way to handle credentials like JWTs in the ADK ecosystem. A great resource to see this in action is the By adopting these patterns, you'll be well-aligned with the "ADK-native" way of handling distributed state and identity. References: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
I am building a distributed Hub-and-Spoke system using the ADK Python SDK.
user_emailas a functional argument (e.g.,get_employee_balance(email=...)) to retrieve the correct records.My Current Implementation
I inject the user context at the session initialization layer (from my UI/Test scripts).
stateobject from the Hub to the Remote Agent via the Agent2Agent Protocol.Currently, I am manually injecting this state into the A2A message
paramsvia middleware so the Remote Agent can receive it and eventually pass theemailto the MCP tool.The Questions
statepropagation? Is there a standard way to pass the "User Context" object alongside the conversation message without manually modifying theparamsdictionary?user_emailstrings now, we plan to move to JWTs later. Does the ADK/A2A ecosystem have a preferred pattern for transporting auth tokens across these agent boundaries?I want to ensure I am aligned with the "ADK-native" way of handling distributed state and identity.
Beta Was this translation helpful? Give feedback.
All reactions