Python A2A: Expose supported_protocol_bindings as configurable parameter#6098
Python A2A: Expose supported_protocol_bindings as configurable parameter#6098giles17 wants to merge 2 commits into
Conversation
Add supported_protocol_bindings parameter to A2AAgent.__init__() allowing users to configure which A2A protocol bindings (JSONRPC, GRPC, HTTP+JSON) the client prefers when connecting to remote agents. - Defaults to ["JSONRPC"] matching current behavior - Passes through to ClientConfig for transport negotiation - Replaces 4 hardcoded references with the configurable value Closes microsoft#6057 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR makes Python A2AAgent transport negotiation configurable by exposing supported_protocol_bindings, while preserving the existing JSONRPC default.
Changes:
- Adds
supported_protocol_bindingstoA2AAgent.__init__(). - Threads the configured bindings into
minimal_agent_card()and streaming/non-streamingClientConfig. - Adds unit tests for custom bindings and default JSONRPC behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
python/packages/a2a/agent_framework_a2a/_agent.py |
Adds and applies configurable A2A protocol binding preferences. |
python/packages/a2a/tests/test_a2a_agent.py |
Adds initialization tests for custom and default protocol bindings. |
There was a problem hiding this comment.
Automated Code Review
Reviewers: 4 | Confidence: 90%
✓ Correctness
Clean, straightforward change that replaces 4 hardcoded JSONRPC references with a user-configurable parameter. The default behavior is preserved via
supported_protocol_bindings or ["JSONRPC"], the variable is correctly scoped before both code branches that use it, and the tests verify both custom and default paths. No correctness issues found.
✓ Security Reliability
The PR is a clean, low-risk feature addition. It correctly uses
Noneas the default to avoid mutable default argument issues, consistently threads the configured bindings through all four usage sites, and includes appropriate tests. No security or reliability concerns identified.
✓ Test Coverage
The PR adds two well-structured tests verifying custom and default protocol bindings are passed to ClientConfig. However, test coverage has a gap: the transport negotiation fallback path (the except block at line ~183 in the diff that creates a fallback_card with
bindings) is not exercised with custom bindings. Additionally, theorpattern (supported_protocol_bindings or ["JSONRPC"]) means an explicitly passed empty list[]silently defaults to["JSONRPC"], which is an untested edge case that may surprise users.
✗ Design Approach
The overall approach is sound, but the new defaulting logic silently overrides one caller-suplied value: passing an explicit empty list for
supported_protocol_bindingsis treated the same as omitting the parameter, so the feature is not fully configurable for all values accepted by its own signature.
Flagged Issues
- Explicit
supported_protocol_bindings=[]is silently rewritten to['JSONRPC']inpython/packages/a2a/agent_framework_a2a/_agent.py:134becauseortreats an empty list as falsy. This means the API's type signature (list[str] | None) accepts a value it cannot faithfully represent. Default only when the parameter isNone.
Automated review by giles17's agents
- Use 'is not None' check instead of 'or' to preserve explicit empty list - Add test verifying empty list is not silently replaced with defaults - Add test verifying fallback path uses custom bindings Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Description
Expose
supported_protocol_bindingsas a configurable parameter onA2AAgent.__init__(), allowing users to specify which A2A protocol bindings the client prefers when connecting to remote agents.Motivation
Per the A2A v1.0 specification (Section 5), agents can declare multiple protocol interfaces (JSONRPC, GRPC, HTTP+JSON) in their AgentCard. Clients need a way to express their binding preference for transport negotiation.
This was previously hardcoded to JSONRPC. This PR makes it user-configurable while preserving the default behavior.
Changes
supported_protocol_bindings: list[str] | None = Noneparameter toA2AAgent.__init__()["JSONRPC"]by default (backward-compatible)ClientConfigfor transport negotiation with the A2A SDK.NET Parity
Aligns with .NET's
A2AClientOptions.PreferredBindingsfrom the A2A SDK NuGet package.Type of Change
Process