Repository navigation
Commit cbb2d84
fix(client): ignore the patch version when preferring a 1.0 interface (a2aproject#1304)
# Description
`ClientFactory._find_best_interface` prefers a 1.0 interface with an
exact string comparison (`protocol_version == '1.0'`). When an agent
card lists a legacy interface and a 1.0 interface written with a patch
version, e.g.
```python
supported_interfaces=[
AgentInterface(url='http://agent/v03', protocol_binding='JSONRPC', protocol_version='0.3.0'),
AgentInterface(url='http://agent/v1', protocol_binding='JSONRPC', protocol_version='1.0.0'),
]
```
the `1.0.0` entry is neither equal to `'1.0'` nor greater than `1.0`, so
the loop falls through to the first `>= 0.3` candidate and the client is
built with `CompatJsonRpcTransport` against `/v03`, i.e. it speaks v0.3
to an agent that supports 1.0. (`'1.0'` and `'1.1'` are handled
correctly.)
The specification's versioning section says patch versions "MUST not be
considered when clients and servers negotiate protocol versions". Patch
versions do show up in practice; several tests in this repo build cards
with `protocol_version='1.0.0'`.
- Compare the `Major.Minor` release
(`packaging.version.Version(...).release[:2]`) instead of the raw
string, via a small `_major_minor` helper (kept out of the loop for
ruff's PERF203).
- Regression test: with `0.3.0` listed first, both `1.0` and `1.0.0`
must select the 1.0 interface and `JsonRpcTransport`. The `1.0.0` case
fails on main with `CompatJsonRpcTransport`.
Checks: `scripts/lint.sh` clean, `uv run pytest` 2183 passed (plus
`tests/integration/cross_version` 5 passed), coverage 93%.
- [x] Follow the [`CONTRIBUTING`
Guide](https://github.com/a2aproject/a2a-python/blob/main/CONTRIBUTING.md).
- [x] Make your Pull Request title in the
<https://www.conventionalcommits.org/> specification.
- [x] Ensure the tests and linter pass
- [x] Appropriate docs were updated (if necessary)
---------
Co-authored-by: mykytanetipa <mykytanetipa@google.com>1 parent e11cb3e commit cbb2d84
2 files changed
Lines changed: 45 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
58 | 64 | | |
59 | 65 | | |
60 | 66 | | |
| |||
229 | 235 | | |
230 | 236 | | |
231 | 237 | | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
236 | 242 | | |
237 | 243 | | |
238 | 244 | | |
| |||
245 | 251 | | |
246 | 252 | | |
247 | 253 | | |
248 | | - | |
249 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
250 | 258 | | |
251 | | - | |
| 259 | + | |
252 | 260 | | |
253 | 261 | | |
254 | 262 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
118 | 148 | | |
119 | 149 | | |
120 | 150 | | |
| |||
0 commit comments