Commit 2a69bf1
liuyuan90
fix(schema): coerce string protocolVersion in InitializeRequest
Some ACP clients (notably Zed) send a date string like "2024-11-05" as
the protocolVersion instead of an integer. The Rust SDK already handles
this gracefully — its Deserialize impl maps any string to V0 with the
comment "Old versions used strings". The Python SDK rejected strings
outright, causing the agent process to crash on the very first handshake.
Changes:
- Add `_coerce_protocol_version` field_validator to `InitializeRequest`
in `src/acp/schema.py` that maps non-integer values to 1 (current
stable version), mirroring the Rust SDK's lenient behaviour.
- Add `CLASS_VALIDATOR_INJECTIONS` table and `_inject_field_validators`
post-processing step to `scripts/gen_schema.py` so the validator is
re-applied automatically on future schema regenerations.
- Add `_ensure_pydantic_import` helper used by the injection step to
add `field_validator` to the generated pydantic import line.
Ref: https://github.com/agentclientprotocol/rust-sdk/blob/main/crates/agent-client-protocol-schema/src/version.rs1 parent df72173 commit 2a69bf1
2 files changed
Lines changed: 86 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 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 | + | |
123 | 148 | | |
124 | 149 | | |
125 | 150 | | |
| |||
182 | 207 | | |
183 | 208 | | |
184 | 209 | | |
| 210 | + | |
185 | 211 | | |
186 | 212 | | |
187 | 213 | | |
| |||
338 | 364 | | |
339 | 365 | | |
340 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
341 | 412 | | |
342 | 413 | | |
343 | 414 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
1588 | 1588 | | |
1589 | 1589 | | |
1590 | 1590 | | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
| 1601 | + | |
| 1602 | + | |
| 1603 | + | |
| 1604 | + | |
1591 | 1605 | | |
1592 | 1606 | | |
1593 | 1607 | | |
| |||
0 commit comments