Repository navigation
google-genai 3.x
ag2[gemini] capped google-genai at <3.0, so Gemini users could not install the current SDK. It now accepts google-genai>=1.68.0,<4, and a fresh pip install "ag2[gemini]" installs 3.x.
The generation API and types did not change in 3.0; both breaking changes concerntransport, and AG2 exposes each of them:
-
API version. On 3.x the Gemini Developer API defaults to
v1instead ofv1beta. The-latestaliases and some-previewmodels exist only onv1beta. Anewapi_versionfield opts back in, and is applied to both generation and the Files API:config = GeminiConfig(model="gemini-flash-latest", api_version="v1beta")
VertexAIConfig.api_versionaccepts"v1"or"v1beta1"; Vertex keepsv1beta1as its default on both SDK majors. -
HTTP client. 3.x uses
httpx2by default.http_clientnow accepts anhttpx2.AsyncClientas well as anhttpx.AsyncClient; existinghttpxclients keepworking on both majors.
Behaviour change. If your environment moves to
google-genai3.x, Gemini Developer API calls go tov1. A model that is available only onv1beta(a-latestalias, some previews) then fails; setapi_version="v1beta"or pingoogle-genai<3.
Deprecation.
google-genai2.x still works in 1.3, butGeminiConfig/VertexAIConfignow emit aDeprecationWarningoncreate()andcreate_files_client(). AG2 1.4.0 will requiregoogle-genai>=3,<4.
Gemini Live input transcription
With InputConfig(transcribe=True), a Gemini Live session on the Gemini API never sent a TranscriptionCompletedEvent for the user's speech: AG2 waited for a finished flag that the Gemini API does not send.
- Gemini 3.x Live (including
gemini-3.5-live-translate-preview) sends one final transcription per utterance, so each one is now completed as it arrives. - Earlier models send fragments. They are joined and completed as one event on
finished, or else when the model's turn ends (generation_complete,interruptedorturn_complete). Wherefinisheddoes arrive, the event now holds the whole utterance instead of only the last fragment.
TranscriptionChunkEvents are sent per message, as before.
Behaviour change. Gemini Live sessions on the Gemini API now emit
TranscriptionCompletedEventfor the user's speech. On a 3.x model it follows a chunk withthe same text.
Fixes
- OpenAI-compatible reasoning:
OpenAICompletionsConfigreadreasoningon complete responses andreasoning_contentwhen streaming, so reasoning was dropped for vLLM, OpenRouter and Ollama-compatible endpoints when streaming, and for DeepSeek and SGLang otherwise. Both fields are now read in both modes, andModelReasoningis emitted once even when a provider fills both. - A2UI: A single-line fenced payload followed by a closing fence on its own line (
```json [...]\n```) was parsed as empty, so the UI was silently notrendered. Only the fence markers are stripped now, which also keeps payloads thatstart on the fence line.
Documentation and project
- The whole
ag2package is now checked with strict mypy, with no per-file allow-list, so new modules are checked as soon as they are added. Most test directoriesare type-checked under a relaxed profile. - CI runs the test suite against
google-genai2.x until support for it is removed.
What's Changed
- chore(deps): bump github/codeql-action/upload-sarif from 4.39.1 to 4.39.3 in the github-actions group by @dependabot[bot] in #3678
- fix(a2ui): keep single-line fenced JSON payload with a standalone closing fenceby @lkuko in #3674
- fix(live): complete Gemini Live input transcription with the whole utterance by @Assertive-xxh in #3686
- feat(gemini): support google-genai 3.x and deprecate 2.x by @vvlrff in #3683
- fix(types): check ag2/network with strict mypy by @vvlrff in #3682
- chore(types): check all of ag2 with strict mypy by @vvlrff in #3688
- chore(types): check root tests with mypy under a relaxed test profile by @vvlrff in #3690
- chore(types): check ag_ui, events, mcp_ui, observer and policies tests with mypy by @vvlrff in #3691
- fix(live): complete Gemini 3.5 Live translate input transcriptions as they arrive by @vvlrff in #3687
- fix(openai): read both reasoning_content and reasoning in completions by @yibol9768-alt in #3684
- chore(types): check response and eval tests with mypy by @vvlrff in #3692
- chore: bump version to 1.3.3 by @vvlrff in #3693
New Contributors
- @lkuko made their first contribution in #3674
- @yibol9768-alt made their first contribution in #3684
Full Changelog: v1.3.2...v1.3.3