fix(sdks): add spark-2 to agent model types
PR #4360 added spark-2 to the /v2/agent schema and made it the default,
but only touched apps/api. No SDK was updated, so spark-2 was
unreachable through the typed surface — the report that started this.
The bigger problem was the response side. GET /v2/agent/:id always
returns `model`, and it is now "spark-2" for any job that omitted one.
Two SDKs validate that field at runtime:
- Python: AgentResponse.model was a pydantic Literal, so parsing raised
ValidationError. It is parsed by get_agent_status, which wait_agent
and the blocking agent() wrapper both call — meaning the whole Python
agent flow failed on the first status poll of a default-model job.
- Rust: the same shape via a serde enum with no matching variant.
Request-side `model` gains spark-2 in Python, JS, Rust, and the Elixir
validator; Java and Go already took plain strings and only needed the
docs corrected.
Response-side `model` is deliberately widened rather than extended:
Python takes a plain str and TS takes `| (string & {})`. The server
ships models without an SDK release, so an exact union here turns every
future model into a crash (Python) or a call-site type error (TS). Rust
gets the variant only — widening to String there would break consumers
matching on the enum, so it stays exhaustive and is a known recurrence
risk.
Regression tests cover a spark-2 status payload and an unreleased model
name; both fail against the previous Literal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> R
Rakshith Ramprakash committed
26e555e0aa6dc1e1586ff964c7556882eebd1d34
Parent: cf1d31b