Restore serde defaults on Model.controls for older-server compatibility

Copilot review flagged that dropping #[serde(default)] makes newer
clients hard-fail against servers that predate the controls field.
The late-added Model fields (default, small_default, configured) set
the precedent: required in the OpenAPI spec, defaulted on
deserialization. An empty controls list already means "unsupported",
so the degraded value is semantically correct.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Bryan Helmkamp 2026-07-24 09:23:18 -04:00
parent 5d8befa6ac
commit 3970c9f545
No known key found for this signature in database

View file

@ -88,6 +88,7 @@ pub struct ModelCosts {
pub struct ModelControls {
/// Exact reasoning-effort values accepted by this provider/model offering.
/// An empty list means the request control is unsupported.
#[serde(default)]
pub reasoning_effort: Vec<ReasoningEffort>,
}
@ -101,6 +102,9 @@ pub struct Model {
pub training: Option<String>,
pub knowledge_cutoff: Option<String>,
pub features: ModelFeatures,
/// Required in API responses; defaulted on deserialization so newer
/// clients tolerate older servers that predate this field.
#[serde(default)]
pub controls: ModelControls,
pub costs: ModelCosts,
pub estimated_output_tps: Option<f64>,