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.rs
Problem
Some ACP clients send a date string like "2024-11-05" as protocolVersion instead of an integer. Zed is a known example — its agent_servers implementation can emit the MCP-style date format during the ACP handshake.
The current Python SDK rejects this outright with a pydantic validation error, causing the agent process to crash immediately after the client connects:
Root cause
The Rust SDK (agent-client-protocol-schema) already handles this gracefully with an explicit comment in the source:
The Python SDK's generated schema.py uses a strict pydantic int type with no equivalent fallback.
Fix
References