Skip to content

feat(gemini): switch the Gemini provider to the Interactions API - #5132

Merged
rumpl merged 1 commit into
docker:mainfrom
rumpl:gemini-interactions-api
Dec 5, 2026
Merged

rumpl merged 1 commit into
docker:mainfrom
rumpl:gemini-interactions-api

Conversation

@rumpl

@rumpl rumpl commented Dec 4, 2026 •

Copy link
Copy Markdown
Member

Summary

Replaces the Gemini provider's generateContent implementation with the Interactions API, which streams function call arguments (arguments_delta). Tool calls now show up in the TUI as soon as Gemini starts writing them, with arguments filling in as they stream.

Changes

  • New request path (request.go, input.go, thinking.go): stateless requests (store: false) that replay the full history as Interactions steps. Leading system messages become the system instruction; later ones are sent as system_input steps. Thought signatures are replayed as thought steps. Tool results are sorted into call order and matched by the call ID Gemini assigned.
  • New stream adapter (stream.go, replaces adapter.go): maps step.start / step.delta / step.stop / interaction.* events to chat deltas. Function calls send their name first, then argument fragments. Interaction statuses map to finish reasons. Usage is summed across the SDK's automatic continuation hops and includes the service tier Google actually used. The request is sent on the first Recv, so the runtime's idle timeout still covers the wait for the first byte.
  • API version: the Gemini Developer API (direct and through the gateway) is pinned to v1beta. The Interactions API is GA on v1, but stream_function_call_arguments is still beta-only: v1 rejects it with a 400, so streaming tool-call arguments needs v1beta. Once the field reaches v1, the geminiAPIVersion constant can switch back. Vertex AI keeps v1beta1.
  • Errors (wrap.go): Interactions client/server errors become StatusError with Retry-After. 400s keep the rejection categories. Malformed or unexpected tool calls still map to ErrInvalidFunctionCall. SDK retries are disabled so the runtime owns retries and fallbacks.
  • Gemini 2.5 dropped: integer thinking budgets are ignored with a warning (the model's default level applies). frequency_penalty, presence_penalty and top_k don't exist in this API and are ignored with a warning. modelinfo.GeminiRejectsThinkingBudget is removed.
  • Docs, agent-schema.json descriptions and examples are updated.

Notes for reviewers

  • The Interactions API has no refusal or safety finish reason that I could find. Failed or cancelled interactions are surfaced as errors.
  • The Docker gateway needs to forward /v1beta/interactions.
  • Saved sessions created with generateContent replay their thought signatures as base64 thought steps. This still needs manual verification against the live API.
  • Gemini integration fixtures pass with DOCKER_AGENT_RUN_GEMINI_INTEGRATION_TESTS=1, except TestCreateBatchEmbedding_VertexPredict, which already fails on main. TestACPRuntimeConfig_ModelSwitchingIsSessionOwned (pkg/acp) also fails on main; nothing in this PR touches it.

@rumpl
rumpl requested a review from a team as a code owner December 4, 2026 23:27
Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:27
@aheritier aheritier added area/docs Documentation changes area/models LLM model integrations and model providers area/providers/gemini Google Gemini provider support area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Dec 4, 2026

This comment was marked as outdated.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:43
@rumpl
rumpl force-pushed the gemini-interactions-api branch from c689421 to 64fe119 Compare December 4, 2026 23:46

This comment was marked as outdated.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:49
@rumpl
rumpl force-pushed the gemini-interactions-api branch from 64fe119 to 5a5905b Compare December 4, 2026 23:55

This comment was marked as outdated.

Copilot AI balanced review requested due to automatic review settings December 4, 2026 23:56

This comment was marked as outdated.

@rumpl
rumpl force-pushed the gemini-interactions-api branch from 5a5905b to 3cbbb25 Compare December 5, 2026 00:01
Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:01

This comment was marked as outdated.

Replace the generateContent implementation with the Interactions API so
function call arguments stream incrementally to the runtime and TUI.

- Requests are stateless (store: false) and replay the full history as
  Interactions steps; thought signatures are replayed as thought steps.
- Function tools enable stream_function_call_arguments; argument deltas
  are forwarded as tool call deltas.
- Pin the Gemini Developer API to v1beta, the only version accepting
  streamed function call arguments. Vertex AI keeps v1beta1.
- Map interaction statuses to finish reasons, sum usage across automatic
  continuation hops and report the actual service tier.
- Classify Interactions HTTP errors with status and Retry-After; SDK
  retries are disabled so the runtime owns retries and fallbacks.
- Drop Gemini 2.5 support: token thinking budgets are ignored with a
  warning, and unsupported sampling parameters (frequency/presence
  penalty, top_k) are ignored with a warning.
- Update docs, schema descriptions and examples accordingly.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
@rumpl
rumpl force-pushed the gemini-interactions-api branch from 3cbbb25 to 3655a4b Compare December 5, 2026 00:21
Copilot AI balanced review requested due to automatic review settings December 5, 2026 00:21

This comment was marked as outdated.

@rumpl
rumpl added this pull request to the merge queue Dec 5, 2026
Merged via the queue into docker:main with commit 40cbcd6 Dec 5, 2026
34 of 36 checks passed
@rumpl
rumpl deleted the gemini-interactions-api branch December 5, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation changes area/models LLM model integrations and model providers area/providers/gemini Google Gemini provider support area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants