mirror of
https://github.com/baserow/baserow.git
synced 2026-12-05 16:58:36 +00:00
* chore(deps): upgrade pydantic-ai to V2 (2.28.0)
Upgrades pydantic-ai-slim from 1.102.0 to 2.28.0. No user-visible behaviour
change: where V2 moved a default, the V1 behaviour is pinned rather than
silently adopted.
Production changes are five files:
assistant/assistant.py async for -> async with ... as events:
(run_stream_events is a context manager)
assistant/retrying_model.py public RunContext; state/metadata/
close_stream proxy delegation; Vertex AI
via GoogleCloudProvider
core/generative_ai/registries.py output_retries=3 -> retries={"output": 3}
assistant/model_profiles.py normalise google-gla/google-vertex prefixes
assistant/tools/database/agents.py pin end_strategy="early"
The rest of the diff is test hardening, and it is the point of the change.
The assistant suite mocked pydantic-ai's streaming path instead of running it,
which hid four real breaks — one of them user-facing:
- Agent(output_retries=3) raises TypeError on V2, breaking the premium
generate_ai_formula endpoint. Invisible because the test patches prompt()
wholesale and the shared fixture refuses structured output.
- run_stream_events became a context manager; the bare async generator mock
kept working regardless.
- end_strategy flipped early -> graceful, letting a previously-skipped tool
call execute and hard-fail formula generation.
- GoogleProvider(vertexai=True) was removed entirely.
The doubles now wrap real pydantic-ai types, one test drives the genuine
streaming path, one proves cancellation unwinds through the context manager,
and test_pydantic_ai_contract.py pins the API surface (public and private) so
the next upgrade fails at import rather than mid-run in production.
Verified: assistant + core/generative_ai 343 passed, 66 skipped; full backend
suite 11962 passed, 360 skipped, 1 failed. That failure
(test_view_empty_count_aggregation_for_interesting_table, BaserowFormulaButtonType
missing empty_query) is pre-existing and unrelated — the identical failure occurs
at base commit 321c00adc, and this branch changes nothing under
backend/src/baserow/contrib/ or premium/.
Note for future upgrades: _ErrorRecoveringStream in retrying_model.py
re-exposes each StreamedResponse class attribute as a delegating property,
because class attributes shadow __getattr__. V2 added state and metadata. That
list must be revisited on every pydantic-ai upgrade — the failure mode is a
wrong value, not an error.
* fix: give Google models a usable HTTP deadline
A bare httpx.AsyncClient defaults to a 5s timeout, and GoogleProvider
forwards that to the Gemini API as an explicit deadline, which the API
rejects because its minimum is 10s. Every Google model was therefore
unusable. Build the client with pydantic-ai's own
create_async_http_client factory instead (600s read, 5s connect).
Also document GOOGLE_API_KEY alongside the other assistant provider
keys, pass it through docker-compose, and bridge it in the eval
conftest so evals can target Gemini.
* fix: resolve GOOGLE_API_KEY explicitly for Google providers
_PROVIDER_ENV had no google entry, so _resolve_credentials fell through
to the deprecated UDSPY_LM_API_KEY and handed whatever it held (e.g. a
Groq key) to Google. It only worked because pydantic-ai reads
GOOGLE_API_KEY itself when no key is passed. Map all four google
prefixes explicitly, matching the other providers' precedence.
Also raise the title-generation timeout from 10s to 15s: 10s is exactly
Gemini's minimum allowed deadline, leaving no margin.