You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: agent_sdks/python/agent_development.md
+87Lines changed: 87 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -397,3 +397,90 @@ agent_card = AgentCard(
397
397
)
398
398
)
399
399
```
400
+
401
+
#### Setting or Propagating Client Capabilities on Remote A2A Agents
402
+
403
+
When calling remote A2A agents (such as delegating to a sub-agent or proxying to a backend A2A stubby agent) via ADK `RemoteA2aAgent`, you must ensure that the remote agent receives the client's UI capabilities in its request metadata under `a2uiClientCapabilities`.
404
+
405
+
You can configure an `A2aRemoteAgentConfig` with a `before_request` interceptor (`RequestInterceptor`) to inject this metadata. There are two common scenarios:
406
+
407
+
##### Scenario 1: Propagating Capabilities from Session State (Orchestrator)
408
+
409
+
When an orchestrator receives an A2A request from a client, it captures the client capabilities into session state. When calling a sub-agent via `RemoteA2aAgent`, the interceptor propagates those capabilities from `ctx.session.state`:
410
+
411
+
```python
412
+
from a2a.types import Message as A2AMessage
413
+
from a2ui.schema.constants importA2UI_CLIENT_CAPABILITIES_KEY
414
+
from google.adk.a2a.agent.config import A2aRemoteAgentConfig, ParametersConfig, RequestInterceptor
415
+
from google.adk.agents.invocation_context import InvocationContext
416
+
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
417
+
418
+
asyncdefpropagate_capabilities_interceptor(
419
+
ctx: InvocationContext,
420
+
message: A2AMessage,
421
+
params: ParametersConfig,
422
+
) -> tuple[A2AMessage, ParametersConfig]:
423
+
# Retrieve capabilities saved earlier in session context state
##### Scenario 2: Explicitly Setting Capabilities for Proxy Agents
447
+
448
+
When acting as a proxy connecting a non-A2A frontend (such as Orcas UI) to a remote A2A backend stubby agent, the incoming frontend request does not have A2A metadata. The proxy agent configures a `before_request` interceptor to explicitly construct and inject the supported client capabilities on outgoing requests:
449
+
450
+
```python
451
+
from a2a.types import Message as A2AMessage
452
+
from a2ui.schema.constants importA2UI_CLIENT_CAPABILITIES_KEY
453
+
from google.adk.a2a.agent.config import A2aRemoteAgentConfig, ParametersConfig, RequestInterceptor
454
+
from google.adk.agents.invocation_context import InvocationContext
455
+
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
456
+
457
+
asyncdefset_proxy_capabilities_interceptor(
458
+
ctx: InvocationContext,
459
+
message: A2AMessage,
460
+
params: ParametersConfig,
461
+
) -> tuple[A2AMessage, ParametersConfig]:
462
+
if message.metadata isNone:
463
+
message.metadata = {}
464
+
465
+
# Explicitly define what the proxy or UI client supports
0 commit comments